Skip to content

Instantly share code, notes, and snippets.

@spg
Created May 31, 2018 03:03
Show Gist options
  • Save spg/489f3cafec5af1a0872371cb41996b51 to your computer and use it in GitHub Desktop.
Save spg/489f3cafec5af1a0872371cb41996b51 to your computer and use it in GitHub Desktop.
CloudFormation AMI usage example
MyAMI:
Type: Custom::AMI
Properties:
ServiceToken: !ImportValue AMILambdaFunctionArn
Image:
Name: my-image
Description: some description for the image
TemplateInstance:
ImageId: ami-467ca739
IamInstanceProfile:
Arn: arn:aws:iam::1234567890:instance-profile/MyProfile-ASDNSDLKJ
UserData:
Fn::Base64: !Sub |
#!/bin/bash -x
yum -y install mysql # provisioning example
# Signal that the instance is ready
INSTANCE_ID=`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id`
aws ec2 create-tags --resources $INSTANCE_ID --tags Key=UserDataFinished,Value=true --region ${AWS::Region}
KeyName: my-key
InstanceType: t2.nano
SecurityGroupIds:
- sg-d7bf78b0
SubnetId: subnet-ba03aa91
BlockDeviceMappings:
- DeviceName: "/dev/xvda"
Ebs:
VolumeSize: '10'
VolumeType: gp2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment