Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,21 +1,66 @@
{
"Parameters": {
"LatestAmiId": {
"Type" : "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
"Description" : "AMI for EC2",
"Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2"
}
},
"Resources": {
"Bucket": {
"Type": "AWS::S3::Bucket"
},
"Instance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"InstanceType": "t2.micro",
"ImageId": { "Ref" : "LatestAmiId" }
}
}
}
"Parameters": {
"LatestAmiId": {
"Description": "AMI for EC2",
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
"Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2"
},
"Message": {
"Description": "Message for HTML page",
"Default": "Cats are the best",
"Type": "String"
}
},
"Resources": {
"InstanceSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Enable SSH and HTTP access via port 22 IPv4 & port 80 IPv4",
"SecurityGroupIngress": [
{
"Description": "Allow SSH IPv4 IN",
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
"CidrIp": "0.0.0.0/0"
},
{
"Description": "Allow HTTP IPv4 IN",
"IpProtocol": "tcp",
"FromPort": "80",
"ToPort": "80",
"CidrIp": "0.0.0.0/0"
}
]
}
},
"Bucket": {
"Type": "AWS::S3::Bucket"
},
"Instance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"InstanceType": "t2.micro",
"ImageId": {
"Ref": "LatestAmiId"
},
"SecurityGroupIds": [
{
"Ref": "InstanceSecurityGroup"
}
],
"Tags": [
{
"Key": "Name",
"Value": "A4L-UserData Test"
}
],
"UserData": {
"Fn::Base64": {
"Fn::Sub": "#!/bin/bash -xe\nyum -y update\nyum -y upgrade\n# simulate some other processes here\nsleep 300\n# Continue\nyum install -y httpd\nsystemctl enable httpd\nsystemctl start httpd\necho \"<html><head><title>Amazing test page</title></head><body><h1><center>${Message}</center></h1></body></html>\" > /var/www/html/index.html\n"
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"Parameters": {
"LatestAmiId": {
"Description": "AMI for EC2",
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
"Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2"
},
"Message": {
"Description": "Message for HTML page",
"Default": "Cats are the best",
"Type": "String"
}
},
"Resources": {
"InstanceSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Enable SSH and HTTP access via port 22 IPv4 & port 80 IPv4",
"SecurityGroupIngress": [
{
"Description": "Allow SSH IPv4 IN",
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
"CidrIp": "0.0.0.0/0"
},
{
"Description": "Allow HTTP IPv4 IN",
"IpProtocol": "tcp",
"FromPort": "80",
"ToPort": "80",
"CidrIp": "0.0.0.0/0"
}
]
}
},
"Bucket": {
"Type": "AWS::S3::Bucket"
},
"Instance": {
"Type": "AWS::EC2::Instance",
"CreationPolicy": {
"ResourceSignal": {
"Timeout": "PT15M"
}
},
"Properties": {
"InstanceType": "t2.micro",
"ImageId": {
"Ref": "LatestAmiId"
},
"SecurityGroupIds": [
{
"Ref": "InstanceSecurityGroup"
}
],
"Tags": [
{
"Key": "Name",
"Value": "A4L-UserData Test"
}
],
"UserData": {
"Fn::Base64": {
"Fn::Sub": "#!/bin/bash -xe\nyum -y update\nyum -y upgrade\n# simulate some other processes here\nsleep 300\n# Continue\nyum install -y httpd\nsystemctl enable httpd\nsystemctl start httpd\necho \"<html><head><title>Amazing test page</title></head><body><h1><center>${Message}</center></h1></body></html>\" > /var/www/html/index.html\n/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackId} --resource Instance --region ${AWS::Region}\n"
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"Parameters": {
"LatestAmiId": {
"Description": "AMI for EC2",
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
"Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2"
},
"Message": {
"Description": "Message for HTML page",
"Default": "Cats are the best",
"Type": "String"
}
},
"Resources": {
"InstanceSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Enable SSH and HTTP access via port 22 IPv4 & port 80 IPv4",
"SecurityGroupIngress": [
{
"Description": "Allow SSH IPv4 IN",
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
"CidrIp": "0.0.0.0/0"
},
{
"Description": "Allow HTTP IPv4 IN",
"IpProtocol": "tcp",
"FromPort": "80",
"ToPort": "80",
"CidrIp": "0.0.0.0/0"
}
]
}
},
"Bucket": {
"Type": "AWS::S3::Bucket"
},
"Instance": {
"Type": "AWS::EC2::Instance",
"Metadata": {
"AWS::CloudFormation::Init": {
"config": {
"packages": {
"yum": {
"httpd": []
}
},
"files": {
"/var/www/html/index.html": {
"content": {
"Fn::Sub": "<html><head><title>Amazing test page</title></head><body><h1><center>${Message}</center></h1></body></html>\n"
}
}
},
"commands": {
"simulatebootstrap": {
"command": "sleep 300"
}
},
"services": {
"sysvinit": {
"httpd": {
"enabled": "true",
"ensureRunning": "true",
"files": [
"/var/www/html/index.html"
]
}
}
}
}
}
},
"CreationPolicy": {
"ResourceSignal": {
"Timeout": "PT15M"
}
},
"Properties": {
"InstanceType": "t2.micro",
"ImageId": {
"Ref": "LatestAmiId"
},
"SecurityGroupIds": [
{
"Ref": "InstanceSecurityGroup"
}
],
"Tags": [
{
"Key": "Name",
"Value": "A4L-UserData Test"
}
],
"UserData": {
"Fn::Base64": {
"Fn::Sub": "#!/bin/bash -xe\n/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource Instance --region ${AWS::Region}\n/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackId} --resource Instance --region ${AWS::Region}\n"
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
"Parameters": {
"LatestAmiId": {
"Description": "AMI for EC2",
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
"Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2"
},
"Message": {
"Description": "Message for HTML page",
"Default": "Cats are the best",
"Type": "String"
}
},
"Resources": {
"InstanceSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Enable SSH and HTTP access via port 22 IPv4 & port 80 IPv4",
"SecurityGroupIngress": [
{
"Description": "Allow SSH IPv4 IN",
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
"CidrIp": "0.0.0.0/0"
},
{
"Description": "Allow HTTP IPv4 IN",
"IpProtocol": "tcp",
"FromPort": "80",
"ToPort": "80",
"CidrIp": "0.0.0.0/0"
}
]
}
},
"Bucket": {
"Type": "AWS::S3::Bucket"
},
"Instance": {
"Type": "AWS::EC2::Instance",
"Metadata": {
"AWS::CloudFormation::Init": {
"config": {
"packages": {
"yum": {
"httpd": []
}
},
"files": {
"/etc/cfn/cfn-hup.conf": {
"content": {
"Fn::Sub": "[main]\nstack=${AWS::StackName}\nregion=${AWS::Region}\ninterval=1\nverbose=true\n"
},
"mode": "000400",
"owner": "root",
"group": "root"
},
"/etc/cfn/hooks.d/cfn-auto-reloader.conf": {
"content": {
"Fn::Sub": "[cfn-auto-reloader-hook]\ntriggers=post.update\npath=Resources.Instance.Metadata.AWS::CloudFormation::Init\naction=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource Instance --region ${AWS::Region}\nrunas=root\n"
},
"mode": "000400",
"owner": "root",
"group": "root"
},
"/var/www/html/index.html": {
"content": {
"Fn::Sub": "<html><head><title>Amazing test page</title></head><body><h1><center>${Message}</center></h1></body></html>\n"
}
}
},
"commands": {
"simulatebootstrap": {
"command": "sleep 300"
}
},
"services": {
"sysvinit": {
"cfn-hup": {
"enabled": "true",
"ensureRunning": "true",
"files": [
"/etc/cfn/cfn-hup.conf",
"/etc/cfn/hooks.d/cfn-auto-reloader.conf"
]
},
"httpd": {
"enabled": "true",
"ensureRunning": "true",
"files": [
"/var/www/html/index.html"
]
}
}
}
}
}
},
"CreationPolicy": {
"ResourceSignal": {
"Timeout": "PT15M"
}
},
"Properties": {
"InstanceType": "t2.micro",
"ImageId": {
"Ref": "LatestAmiId"
},
"SecurityGroupIds": [
{
"Ref": "InstanceSecurityGroup"
}
],
"Tags": [
{
"Key": "Name",
"Value": "A4L-UserData Test"
}
],
"UserData": {
"Fn::Base64": {
"Fn::Sub": "#!/bin/bash -xe\n/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource Instance --region ${AWS::Region}\n/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackId} --resource Instance --region ${AWS::Region}\n"
}
}
}
}
}
}