Improve experience for renaming L1s
See original GitHub issueUsing a L2 construct (I think that’s how you refer to them) to define a resource doesn’t allow me to explicitly define the resource’s logical name.
new Role(stack, "FunctionRole", {
assumedBy: new ServicePrincipal('lambda.amazonaws.com')
});
==>
FunctionRole111A5701:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Statement:
-
Action: 'sts:AssumeRole'
Effect: Allow
Principal:
Service: lambda.amazonaws.com
Version: '2012-10-17'
Reasons that I’d like to be able to set the logical name precisely:
-
if I need to look at my template to debug anything, or if I have workflows that involve inspecting templates in API responses or the console UI, it can be easier to deal with if I can explicitly set my resource’s logical name
-
if I have to resort to L1 constructs from ‘@aws-cdk/resources’, the pattern is changed – while the
name
argument looks the same, I end up without a suffixed logical resource name
new logs.LogGroupResource(stack, 'Logs', {
logGroupName: new FnSub('/aws/lambda/${AWS::StackName}') as any,
retentionInDays: 14
});
==>
Logs:
Type: 'AWS::Logs::LogGroup'
Properties:
LogGroupName:
'Fn::Sub': '/aws/lambda/${AWS::StackName}'
RetentionInDays: 14
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:16 (8 by maintainers)
Top Results From Across the Web
How to use new Poke Genie iOS Keyboard for IV analysis and ...
How to use new Poke Genie iOS Keyboard for IV analysis and renaming.
Read more >Chapter 3 Instruction-Level Parallelism and Its Exploitation
registers by physical renaming registers happens effectively in 1 cycle, ... an improvement in the branch prediction rate and a reduction in the...
Read more >Cache Design Options for a Clustered Multithreaded ...
A shared L1 cache has the benefit of potentially increasing cache capacity for ... tion is fetched, it is decoded, renamed, and steered...
Read more >An interactive tool for pronunciation training - ScienceDirect.com
Another common belief among teachers is that pronunciation improvement will ... Learners also have the option to rename, copy, and delete the Anchor...
Read more >A Highly Productive Implementation of an Out-of-Order ...
process scaling, continued performance improvement relies on a number of small-scale micro ... 2.5.2 The Physical Register File Design (Explicit Renaming) .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Obviously that’s a good point.
In the meantime, you could synthesize first to determine the generated ID and then use “rename” but that’s a very broken experience.
Let us give this a bit of thought. Reopening for now.
Contrary to CloudFormation, which is a flat list of resources, CDK stacks form a tree. We need a way to assign unique and stable Logical IDs that won’t cause conflicts.
From the
concepts.html#logical-ids
documentation topic (#209 includes some improvements):When you synthesize a stack into an AWS CloudFormation template, the CDK assigns a logical ID, which must be unique within the template, to each resource in the stack.
Each resource in the construct tree has a unique path that represents its location within the tree. The logical ID of a resource is formed by concatenating the names of all of the constructs in the resource’s path, and appending an eight-character MD5 hash of the path. This final component is necessary since AWS CloudFormation logical IDs cannot include the delimiting slash character (/), so simply concatenating the component values does not work. For example, concatenating the components of the path /a/b/c produces abc, which is the same as concatenating the components of the path /ab/c.
Since logical IDs can only use alphanumeric characters and also restricted in length, we are unable to simply use a delimited path as the logical ID. Instead IDs are allocated by concatenating a human-friendly rendition from the path (concatenation, de-duplicate, trim) with a short MD5 hash of the delimited path:
Low-level CloudFormation Resources that are direct children of the
Stack
class use their name as their logical ID without modification. This makes it easier to port existing templates into a CDK app.This scheme ensures that:
The AWS CDK applies some heuristics to improve the human-friendliness of the prefix:
Renaming Logical IDs
The :py:meth:
aws-cdk.Stack.renameLogical
method can be used to explicitly assign logical IDs to certain resources, given either their full path or