In CDK I couldn't find from documentation how I can get ProvisioningArtifactIds
e.g. pa-4abcdjnxjj6ne
? CloudFormation will return the value, but not CDK.
(Edit: in CF, ProductId: !Ref Product
and ProvisioningArtifactId: !GetAtt Product.ProvisioningArtifactIds
)
I need it, so I can make a CloudFormation Product
product = aws_servicecatalog.CloudFormationProduct(self, "Product",
product_name="My Product",
owner="Product Owner",
product_versions=[servicecatalog.CloudFormationProductVersion(
product_version_name="v1",
cloud_formation_template=servicecatalog.CloudFormationTemplate.from_product_stack(S3BucketProduct(self, "S3BucketProduct"))
)])
and later in the same stack make the association
aws_servicecatalog.CfnServiceActionAssociation(
self,
"serviceId",
product_id=product.product_id,
provisioning_artifact_id="????", # ????
service_action_id=myServiceAction.attr_id,
)
CodePudding user response:
The CloudFormation docs list the return values for the resource.
The !Ref Product
value is easy. The CDK source code shows it is exposed directly on the L2 CloudFormationProduct
as product_id
.
# !Ref Product
ref = product.product_id
The !GetAtt Product.ProvisioningArtifactIds
value is trickier. First reference the underlying L1 CfnCloudFormationProduct
construct with escape hatch syntax. Then call get_att
:
# !GetAtt Product.ProvisioningArtifactIds
cfn_product = product.node.default_child
get_att = cfn_product.get_att("ProvisioningArtifactIds")