1 réponse
- Le plus récent
- Le plus de votes
- La plupart des commentaires
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() ) }
répondu il y a 7 mois
Contenus pertinents
- demandé il y a 9 mois
- demandé il y a un an
- AWS OFFICIELA mis à jour il y a 3 ans
- AWS OFFICIELA mis à jour il y a 3 ans
- AWS OFFICIELA mis à jour il y a 3 ans
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.