1 Answer
- Newest
- Most votes
- Most comments
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() ) }
answered 7 months ago
Relevant content
- asked 3 years ago
- asked 2 years ago
- asked 5 months ago
- asked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
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.