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公式更新しました 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.