flaviostutz / flaviostutz/cdk-practical-constructs
Simplified `network` config
- 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
Assessment
This issue has not been assessed yet.