This is a CloudFormation Macro that will get information about whether an instance type is available in the AZs
where the instance could be built. Needed this because the InstanceType parameter was failing for some regions for the
t4g.small instance type in us-east-1 region.
| Property Name | Description |
|---|---|
| InstanceType | The Instance Type we want to check for availability in all the subnets |
| Subnets | The subnets we want to check against (will be all in the VPC generally) passed as an array |
| Name | Description |
|---|---|
| AvailableInAZs | The zones that have the instance type (array) |
| AvailableInASubnetIds | The SubnetIds that have the instance type (comma separated) |
# Custom resource to get subset of zones that have the instance type available
InstanceTypAZCheck:
Type: Custom::CheckInstanceTypeAvailability
Properties:
ServiceToken: arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:InstanceTypAZCheck
InstanceType: !Ref InstanceType
Subnets:
Fn::Split:
- ","
- Fn::ImportValue: !Sub '${VPCDataStackName}-SubnetIds' This is the Lambda code for the Macro. It gets the VPC ID and returns the subnet IDs and count of subnets in the VPC.
This script creates the role with the permissions that the Lambda needs and deploys the Lambda initially. Probably could
combine this with the update.sh to make things easier.
To run this script, you must have a valid session, and the region must be set. In most cases this simply means you set these variables:
AWS_PROFILEthe name of a profile in your~/.aws/configor~/.aws/credentialsfile, e.g. -wf-bia-devAWS_REGIONthe region you are going to deploy in (normally this will beus-west-2)
The steps of this script are as follows:
- creates a role with the
trust-policy.jsonand then attaches policies that the Lambda will need. - builds the
InstanceTypAZCheck.go - Deploys the Lambda to the proper account.
This script updates the Lambda code (particularly useful during development) same variables apply as for create.sh
The steps of this script are as follows:
- builds the
InstanceTypAZCheck.go - Deploys the Lambda to the proper account.
The Trust policy for Lambda to use the role that is created in create.sh