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년 전
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.