-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Description
I've had issues when using crhelper to get it return attributes back to the stack.
This very simple lambda works.
def on_event(event, context):
props = event["ResourceProperties"]
print("create new resource with props %s" % props)
message = event['ResourceProperties']['RERUN']
product_id = sc.search_products_as_admin(
Filters={
'FullTextSearch': ['AWS Control Tower Account Factory']
},
)['ProductViewDetails'][0]['ProductViewSummary']['ProductId']
artifact_id = sc.describe_product_as_admin(
Id = product_id
)['ProvisioningArtifactSummaries'][0]['Id']
attributes = {
'ProductId': product_id,
'ArtifactId': artifact_id
}
return { 'Data': attributes }
if i replace it with this;
import crhelper
import boto3
helper = crhelper.CfnResource()
@helper.create
@helper.update
def get_account_factory_id(event, _):
sc = boto3.client('servicecatalog')
product_id = sc.search_products_as_admin(
Filters={
'FullTextSearch': ['AWS Control Tower Account Factory']
},
)['ProductViewDetails'][0]['ProductViewSummary']['ProductId']
helper.Data['ProductId'] = product_id
artifact_id = sc.describe_product_as_admin(
Id = product_id
)['ProvisioningArtifactSummaries'][0]['Id']
helper.Data['ArtifactId'] = artifact_id
@helper.delete
def no_op(_, __):
pass
def on_event( event, context ):
helper(event, context)
I end up with this error.
The stack named AccountfactoryStack failed to deploy: CREATE_FAILED (CustomResource attribute error: Vendor response doesn't contain ArtifactId key in object arn:aws:cloudformation:ap-southeast-2:4xxxxxxxx7:stack/AccountfactoryStack/71875c50-f5a8-11ec-ac83-06c5a6d5f3f0|accountTahiprovisioningArtifactIdD6FC5169|5c9f7268-d6e5-45f5-b2fb-8cafdb68e1ee in S3 bucket cloudformation-custom-resource-storage-apsoutheast2)
It appears that somethign might be broken here. I love the idea of crhelper, its great, but not being able to use attributes is a killer.
Metadata
Metadata
Assignees
Labels
No labels