From 92cc26657d1fdc48968bc77da789d5f8c99e41ab Mon Sep 17 00:00:00 2001 From: Mike Neverov Date: Tue, 5 May 2026 12:46:34 +0100 Subject: [PATCH] init --- changelog.md | 4 ++++ functions/default-vpc.js | 5 +++++ package.json | 2 +- readme.md | 2 ++ test/default-vpc.test.js | 12 +++++++----- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/changelog.md b/changelog.md index fc1b58f..1a1d2f3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +### 4.1.0 + +Adds `FargateArm64PrivateSubnets` to the DefaultVpc resource. + ### 4.0.0 Updates to Node 22.x diff --git a/functions/default-vpc.js b/functions/default-vpc.js index 1e839fb..3a639fe 100644 --- a/functions/default-vpc.js +++ b/functions/default-vpc.js @@ -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'); @@ -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); diff --git a/package.json b/package.json index 1083192..9ec8ff0 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/readme.md b/readme.md index 5143ef5..c2d924a 100644 --- a/readme.md +++ b/readme.md @@ -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 diff --git a/test/default-vpc.test.js b/test/default-vpc.test.js index 017c56c..3f993fb 100644 --- a/test/default-vpc.test.js +++ b/test/default-vpc.test.js @@ -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 } ] })); }); @@ -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');