aws / aws/aws-cdk

ec2: PrefixList.fromLookup should support tokens, particularly cdk.Aws.REGION

Open
#34,753 4 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-ec2 feature-request p3
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

The highly requested #15115 led to the development of `PrefixList.fromLookup`. However, trying to use it proved to be a bit tricky. The following code does not work:

```ts
const s3PrefixList = ec2.PrefixList.fromLookup(this, 'S3PrefixList', {
prefixListName: `com.amazonaws.${cdk.Aws.REGION}.s3`,
});
```

Tokens such as `cdk.Aws.REGION` are not allowed: https://github.com/aws/aws-cdk/blob/aea1372ab7bc68c489cea5ee5e499233755910e8/packages/aws-cdk-lib/aws-ec2/lib/prefix-list.ts#L168-L171

### Use Case

Using `cdk.Aws.REGION` is very convenient, because it is accessible anywhere, quite easily. If I need a non-tokenized region value, I will have to hard-code it to stack params, and cascade it over the entire construct tree.

### Proposed Solution

Just allow the `cdk.Aws.REGION` to be used within `prefixListName` of the `PrefixList.fromLookup` method.

### Other Information

_No response_

### Acknowledgements

- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### AWS CDK Library version (aws-cdk-lib)

2.201.0

### AWS CDK CLI version

2.1018.1 (build cb71364)

### Environment details (OS name and version, etc.)

Win11

Contributor guide

Open the contributing guide

Research direction

Start in aws-ec2/lib/prefix-list.ts at the validation linked in the issue, then inspect the existing PrefixList.fromLookup tests. Confirm that a tokenized prefixListName such as cdk.Aws.REGION is accepted and add coverage showing the lookup works with it.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.