flaviostutz / flaviostutz/cdk-practical-constructs

Simplified `network` config

Open
#11 4 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
7
Forks
7
PR merge metrics
No merged PRs in 30d

Description

Hi!

I saw the `network` prop that makes it easier to populate the VPC and the subnets for the Lambda.

What I disliked is that I had to supply more properties than vpcID and subnetIDs, but also the route table and availability zones.

I found out a quicker way to achieve the same, by just using the default CDK lambda props, instead of the `network` prop.

Example:

```ts
const vpc = ec2.Vpc.fromLookup(this, 'VPC', {
vpcId: 'vpc-xxxxxxxxxxxxxxxxx',
});

const myLambda = new BaseNodeJsFunction(
this,
'MyLambda',
{
/*
other props
*/
vpc: vpc,
vpcSubnets: {
subnetFilters: [
ec2.SubnetFilter.byIds([
'subnet-aaaaaaaa',
'subnet-bbbbbbbb',
'subnet-cccccccc',
]),
],
},
},
);
```

Now I only have to know the vpcId and the subnet IDs.

@flaviostutz What do you think of this approach?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.