Skip to content

Custom resource capitalises properties - undocumented #4896

@TomDufall

Description

@TomDufall

When creating a custom resource, you can add in properties. These properties get capitalised. This is documented in the code, but not the documentation pages.

Documentation in code
Usage in code

/**

  • Uppercase the first letter of every property name
  • It's customary for CloudFormation properties to start with capitals, and our
  • properties to start with lowercase, so this function translates from one
  • to the other
    */

Reproduction Steps

CDK definition

db_initialiser = aws_cfn.CustomResource(
    self, "db_initialiser",
    properties={"es_endpoint": self.es_domain.attr_domain_endpoint},
    provider=aws_cfn.CustomResourceProvider.lambda_(
        aws_lambda.SingletonFunction(
            self, "db_init_singleton",
            code=aws_lambda.Code.asset("efar/elasticsearch_config"),
            handler="es_config_custom_resource.event_handler",
            runtime=aws_lambda.Runtime.PYTHON_3_7,
            timeout=core.Duration.seconds(300),
            uuid="1c23d474-74c3-4adc-8d1d-760e56c2d681",
            )
        )
    )

Error Log

Cloudwatch log

[DEBUG] 2019-11-06T16:42:19.234Z f54b36c0-da56-4f2c-9069-2769094304ce {'RequestType': 'Create', 'ServiceToken': 'arn:aws:lambda:eu-west-2:536099501702:function:efar-elasticsearch-test3-SingletonLambda1c23d47474-BWVU5Q9UOYAF', 'ResponseURL': 'https://cloudformation-custom-resource-response-euwest2.s3.eu-west-2.amazonaws.com/arn%3Aaws%3Acloudformation%3Aeu-west-2%3A536099501702%3Astack/efar-elasticsearch-test3/e5e9b9a0-00b2-11ea-b5e6-02317fefc7aa%7Cessubstackdbinitialiser8B803743%7C4a954972-49c7-461f-8578-869fae154ff1?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20191106T164218Z&X-Amz-SignedHeaders=host&X-Amz-Expires=7199&X-Amz-Credential=AKIAZYWU4JB3S7SC2XN6%2F20191106%2Feu-west-2%2Fs3%2Faws4_request&X-Amz-Signature=65ca19224c3cac34e954e46dedcba9cf9a21c996117ac84349f0df6c0a549528', 'StackId': 'arn:aws:cloudformation:eu-west-2:536099501702:stack/efar-elasticsearch-test3/e5e9b9a0-00b2-11ea-b5e6-02317fefc7aa', 'RequestId': '4a954972-49c7-461f-8578-869fae154ff1', 'LogicalResourceId': 'essubstackdbinitialiser8B803743', 'ResourceType': 'AWS::CloudFormation::CustomResource', 'ResourceProperties': {'ServiceToken': 'arn:aws:lambda:eu-west-2:536099501702:function:efar-elasticsearch-test3-SingletonLambda1c23d47474-BWVU5Q9UOYAF', 'Es_endpoint': 'search-efar-db-test3-ayfzxubo47v3xtswcvdrakbnxu.eu-west-2.es.amazonaws.com'}}

Specifically:

'ResourceProperties':{
    'ServiceToken': 'arn:aws:lambda:eu-west-2:536099501702:function:efar-elasticsearch-test3-SingletonLambda1c23d47474-BWVU5Q9UOYAF',
    'Es_endpoint': 'search-efar-db-test3-ayfzxubo47v3xtswcvdrakbnxu.eu-west-2.es.amazonaws.com'
}

Environment

  • CLI Version : 1.15.0
  • Framework Version: 1.15.0
  • OS : Linux
  • Language : Python

Other

Personally, I'd rather properties keep the name I give them - it's unintuitive for things to rename themselves. However, this would be a breaking change, so it would probably be best to simply change the documentation to highlight this feature.


This is 🐛 Bug Report

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions