Replies: 2 comments 1 reply
-
this might be related to #19309 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hey, I'm curious if there's any specific issue with the current logical ID name. These names are only identifiers for CloudFormation, they generally don't need to be that descriptive unless you need to inspect the template That said, you could use an aspect on the provider resource. Take the following as an example: const app = new cdk.App();
const stack = new TestingStack(app, 'TagVisitStack', {
env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: 'us-east-1' },
});
class LogicalIdModifier implements cdk.IAspect {
public visit(node: IConstruct): void {
if (!(node instanceof cdk.CfnResource)) return;
(node as cdk.CfnResource).overrideLogicalId(`CustomResourceProvider${node.node.addr}`);
}
}
cdk.Aspects.of(stack.crProvider).add(new LogicalIdModifier());
---
export class TestingStack extends cdk.Stack {
public crProvider: lambda.Function;
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
new cr.AwsCustomResource(this, 'CustomResource', {
onCreate: {
service: 'S3',
action: 'putObject',
physicalResourceId: cr.PhysicalResourceId.of('CustomResource'),
},
policy: cr.AwsCustomResourcePolicy.fromSdkCalls({ resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE }),
});
this.crProvider = this.node.children.find((child) => child instanceof lambda.Function && child.node.id.startsWith('AWS')) as lambda.Function;
}
} If you just want to change the id of the function and not of all the children of the function, you could forego the aspect and instead just add this in your stack const providerFn = this.node.children.find((child) => child instanceof lambda.Function && child.node.id.startsWith('AWS')) as lambda.Function;
(providerFn.node.defaultChild as lambda.CfnFunction).overrideLogicalId('CustomResourceLambda'); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have this piece of code that I adapted from somewhere to allow me to get SSM parameters from another region:
this is invoked in my stack like this:
it all works fine, but I get this into my synthesized cloudformation template:
Is there any way I can customize the resource name? i.e
AWS679f53fac002430cb0da5b7982bd22872D164C4C
into something more meaningful.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions