Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crhelper appears tp break #63

Open
mrpackethead opened this issue Jun 27, 2022 · 0 comments
Open

crhelper appears tp break #63

mrpackethead opened this issue Jun 27, 2022 · 0 comments

Comments

@mrpackethead
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant