Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 4.1.0

Adds `FargateArm64PrivateSubnets` to the DefaultVpc resource.

### 4.0.0

Updates to Node 22.x
Expand Down
5 changes: 5 additions & 0 deletions functions/default-vpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ var AWS = require('aws-sdk');
var utils = require('../lib/utils');
var Response = require('../lib/response');

var FARGATE_ARM64_UNSUPPORTED_AZ_IDS = ['use1-az3'];

module.exports = function(event, context) {
if (!utils.validCloudFormationEvent(event))
return context.done(null, 'ERROR: Invalid CloudFormation event');
Expand Down Expand Up @@ -44,6 +46,9 @@ module.exports = function(event, context) {

info.PublicSubnets = publicSubnets.map((subnet) => subnet.SubnetId);
info.PrivateSubnets = privateSubnets.map((subnet) => subnet.SubnetId);
info.FargateArm64PrivateSubnets = privateSubnets
.filter((subnet) => !FARGATE_ARM64_UNSUPPORTED_AZ_IDS.includes(subnet.AvailabilityZoneId))
.map((subnet) => subnet.SubnetId);
info.RouteTable = results[1].RouteTables[0].RouteTableId;
info.RouteTables = results[1].RouteTables.map((rt) => rt.RouteTableId);
response.setId(info.VpcId);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mapbox/magic-cfn-resources",
"version": "4.0.0",
"version": "4.1.0",
"description": "Build Lambda-backed custom CloudFormation resources",
"main": "index.js",
"directories": {
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ You can use `Fn::GetAtt` to obtain the following data:
- AvailabilityZones: an array of strings representing the VPC's availability zones
- AvailabilityZoneCount: the number of availability zones
- PublicSubnets: an array of strings representing the VPC's public subnets
- PrivateSubnets: an array of strings representing the VPC's private subnets
- FargateArm64PrivateSubnets: an array of private subnet IDs excluding availability zones where Fargate ARM64 is unsupported
- RouteTable: the ID for the first route table in the VPC
- RouteTables: IDs of all of the route tables in the VPC

Expand Down
12 changes: 7 additions & 5 deletions test/default-vpc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ test('[default VPC] success', (assert) => {
Subnets: [
{ SubnetId: 'a', AvailabilityZone: '1a', MapPublicIpOnLaunch: true },
{ SubnetId: 'b', AvailabilityZone: '1b', MapPublicIpOnLaunch: true },
{ SubnetId: 'c', AvailabilityZone: '1c', MapPublicIpOnLaunch: false }
{ SubnetId: 'c', AvailabilityZone: '1c', AvailabilityZoneId: 'use1-az3', MapPublicIpOnLaunch: false },
{ SubnetId: 'd', AvailabilityZone: '1d', AvailabilityZoneId: 'use1-az6', MapPublicIpOnLaunch: false }
]
}));
});
Expand All @@ -51,12 +52,13 @@ test('[default VPC] success', (assert) => {
VpcId: 'vpcid',
AvailabilityZones: ['1a','1b'],
AvailabilityZoneCount: 2,
PrivateSubnetAvailabilityZones: ['1c'],
PrivateSubnetAvailabilityZoneCount: 1,
PrivateSubnetAvailabilityZones: ['1c', '1d'],
PrivateSubnetAvailabilityZoneCount: 2,
AzIndexedPublicSubnets: ['a', 'b', { Ref: 'AWS::NoValue' }, { Ref: 'AWS::NoValue' }, { Ref: 'AWS::NoValue' }, { Ref: 'AWS::NoValue' }],
AzIndexedPrivateSubnets: [{ Ref: 'AWS::NoValue' }, { Ref: 'AWS::NoValue' }, 'c', { Ref: 'AWS::NoValue' }, { Ref: 'AWS::NoValue' }, { Ref: 'AWS::NoValue' }],
AzIndexedPrivateSubnets: [{ Ref: 'AWS::NoValue' }, { Ref: 'AWS::NoValue' }, 'c', 'd', { Ref: 'AWS::NoValue' }, { Ref: 'AWS::NoValue' }],
PublicSubnets: ['a', 'b'],
PrivateSubnets: ['c'],
PrivateSubnets: ['c', 'd'],
FargateArm64PrivateSubnets: ['d'],
RouteTable: 'x',
RouteTables: ['x', 'z']
}, 'returns expected info');
Expand Down
Loading