Created
February 27, 2023 11:57
-
-
Save peterjgrainger/adef4103ee19e9c2aa5d386185115c92 to your computer and use it in GitHub Desktop.
auto-remediate-wrong-availability-zone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parameters: | |
instanceType: | |
Description: Instance type | |
Type: String | |
Default: r6i.xlarge | |
availabilityZone: | |
Description: Availability Zone | |
Type: String | |
Default: us-east-1i | |
vpcId: | |
Description: VPC ID | |
Type: String | |
Default: <insert-default> | |
Resources: | |
myEC2Instance: | |
Type: AWS::EC2::Instance | |
Properties: | |
ImageId: ami-0a313d6098716f372 | |
InstanceType: !Ref instanceType | |
Monitoring: true | |
AvailabilityZone: !Ref availabilityZone | |
SecurityGroupIds: | |
- !Ref secGroupName | |
UserData: !Base64 | | |
#!/bin/bash -ex | |
# put your script here | |
Tags: | |
- Key: key | |
Value: value | |
secGroupName: | |
Type: AWS::EC2::SecurityGroup | |
Properties: | |
GroupName: sg1 | |
GroupDescription: sg1 | |
VpcId: !Ref vpcId | |
SecurityGroupIngress: | |
- IpProtocol: tcp | |
FromPort: 22 | |
ToPort: 22 | |
CidrIp: 0.0.0.0/0 | |
SecurityGroupEgress: | |
- IpProtocol: tcp | |
FromPort: 0 | |
ToPort: 65535 | |
CidrIp: 0.0.0.0/0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update the default VPC ID
aws cloudformation create-stack --stack-name myteststack --template-body file://create-instance.yaml --disable-rollback --region us-east-1
aws cloudformation wait stack-create-complete --stack-name myteststack --region us-east-1
aws cloudformation update-stack --stack-name myteststack --template-body file://create-instance.yaml --region us-east-1 --disable-rollback --parameters ParameterKey=availabilityZone,ParameterValue=us-east-1a