Skip to content

ec2: support PrefixList.fromLookup() #33606

@Tietew

Description

@Tietew

Describe the feature

AWS-managed prefix lists are listed in AWS documentation.
https://docs.aws.amazon.com/vpc/latest/userguide/working-with-aws-managed-prefix-lists.html

But PrefixListId differ per region and account.
We should copy&paste id from AWS console or CLI output.

Use Case

For example, this is useful that an ALB needs to allow HTTP(S) connections from CloudFront only.

const plCloudFront = ec2.PrefixList.fromLookup(this, 'CloudFrontPrefixList', {
  prefixListName: 'com.amazonaws.global.cloudfront.origin-facing',
});
alb.connections.allowFrom(ec2.Peer.perfixListId(plCloudFront.prefixListId), ec2.Peer.HTTPS);

Proposed Solution

CloudControl context provider may query prefix list from name.

PoC code:

ContextProvider.getValue(scope, {
  provider: cxschema.ContextProvider.CC_API_PROVIDER,
  props: {
    typeName: 'AWS::EC2::PrefixList',
    propertyMatch: {
      PrefixListName: 'com.amazonaws.global.cloudfront.origin-facing',
    },
    propertiesToReturn: ['PrefixListId'],
  },
})

By CLI:

$ aws cloudcontrol list-resources --type-name 'AWS::EC2::PrefixList' | jq '.ResourceDescriptions[]|select((.Properties|fromjson).PrefixListName=="com.amazonaws.global.cloudfront.origin-facing")'
{
  "Identifier": "pl-xxxxxxxx",
  "Properties": "{\"OwnerId\":\"AWS\",\"PrefixListId\":\"pl-xxxxxxxx\",...}"
}

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.180.0

Environment details (OS name and version, etc.)

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ec2Related to Amazon Elastic Compute Cloudeffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions