1 回答
- 最新
- 投票最多
- 评论最多
0
Edit - updated to retry until the stack arn is present on the record outputs...
The only solution I've so far found is to set it immediately after creation using the SDK.
import software.amazon.awssdk.services.cloudformation.CloudFormationClient import software.amazon.awssdk.services.cloudformation.model.UpdateTerminationProtectionRequest import software.amazon.awssdk.services.servicecatalog.ServiceCatalogClient import software.amazon.awssdk.services.servicecatalog.model.DescribeRecordRequest import software.amazon.awssdk.services.servicecatalog.model.ProvisionProductRequest import java.time.Duration import java.time.Instant.now val serviceCatalogClient = ServiceCatalogClient.create() val cloudFormationClient = CloudFormationClient.create() val provisionProductResponse = serviceCatalogClient.provisionProduct(ProvisionProductRequest.builder() // TODO add params! .build() ) var stackArn: String? = null val timeout = now() + Duration.ofSeconds(20) while (stackArn == null && now() < timeout) { Thread.sleep(Duration.ofSeconds(1).toMillis()) val record = serviceCatalogClient.describeRecord(DescribeRecordRequest.builder() .id(provisionProductResponse.recordDetail().recordId()) .build() ) stackArn = record .recordOutputs() ?.singleOrNull { it.outputKey() == "CloudformationStackARN" } ?.outputValue() } if (stackArn != null) { cloudFormationClient.updateTerminationProtection(UpdateTerminationProtectionRequest.builder() .stackName(stackArn) .enableTerminationProtection(true) .build() ) }
已回答 7 个月前
相关内容
- AWS 官方已更新 3 年前
- AWS 官方已更新 2 年前
- AWS 官方已更新 3 年前
- AWS 官方已更新 3 年前
Trying the third option, but just getting from the result of
serviceCatalogClient.provisionProduct
to an actual cloudformation stack in the AWS SDK v2 seems to be a labour of Hercules - bafflingly complicated.