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

Adding tags to the underling lambda of a SingletonFunction #1079

Closed
AdamBoxall opened this issue Nov 5, 2018 · 3 comments
Closed

Adding tags to the underling lambda of a SingletonFunction #1079

AdamBoxall opened this issue Nov 5, 2018 · 3 comments
Assignees
Labels
@aws-cdk/aws-lambda Related to AWS Lambda feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged.

Comments

@AdamBoxall
Copy link
Contributor

AdamBoxall commented Nov 5, 2018

There's no direct or simple way of constructing a SingletonFunction and providing tags to the underlying lambda. In some organisations it's a requirement to tag any resources that handle or store sensitive data, such as PII.

The normal workaround would be to use findChild("Resource") to get the CFN-level resource object, and override the tags property. However as the underlying lambda of a singleton function is a sibling, not a descendant, that does not work.

Instead you have to access the children of the current stack and findChild() using the ID given to the lambda, based upon the lambdaPurpose and uuid props:

const lambda = Stack.find(this).findChild("LambdaPurposeUUID");
const resource = lambda.findChild("Resource") as FunctionResource;

(There's some formatting applied to both of those props to strip out invalid characters)

@moofish32
Copy link
Contributor

Let me add a test over here and see if this can catch your use case too. If you have a test stack in a gist, I'll grab that directly.

@AdamBoxall
Copy link
Contributor Author

Sure. Here's a barebones stack that solves the problem using the workaround described above:

https://gist.github.com/AdamBoxall/afd6a97eb04a5dd100e4783653cca403

@rix0rrr rix0rrr added the feature-request A feature should be added or improved. label Nov 6, 2018
@SomayaB SomayaB added the @aws-cdk/aws-lambda Related to AWS Lambda label Sep 10, 2019
@SomayaB SomayaB added the needs-triage This issue or PR still needs to be triaged. label Sep 10, 2019
@SomayaB
Copy link
Contributor

SomayaB commented Sep 17, 2019

Closing this issue since there hasn't been any activity on it in a while. Feel free to reopen.

@SomayaB SomayaB closed this as completed Sep 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

5 participants