Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #14 from youngjeong46/develop
Browse files Browse the repository at this point in the history
Updating templates for SigV4 compatibility. Details: https://fwd.aws/…
  • Loading branch information
davmayd authored May 21, 2020
2 parents 893f16d + 06503fb commit d9609cb
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 81 deletions.
126 changes: 113 additions & 13 deletions templates/workload-json-master.template
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
},
"Parameters": [
"QSS3BucketName",
"QSS3BucketRegion",
"QSS3KeyPrefix"
]
}
Expand Down Expand Up @@ -89,10 +90,10 @@
"default": "Quick Start S3 bucket name"
},
"QSS3KeyPrefix": {
"default": "Quick Start S3 key prefix"
"default": "Quick Start S3 Key Prefix"
},
"S3BucketName": {
"default": "S3 Bucket Name"
"default": "S3 bucket name"
},
"RemoteAccessCIDR": {
"default": "Allowed bastion external access CIDR"
Expand Down Expand Up @@ -195,6 +196,11 @@
"Description": "S3 bucket name for the Quick Start assets. This string can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-).",
"Type": "String"
},
"QSS3BucketRegion": {
"Default": "us-east-1",
"Description": "The AWS Region where the Quick Start S3 bucket (QSS3BucketName) is hosted. When using your own bucket, you must specify this value.",
"Type": "String"
},
"QSS3KeyPrefix": {
"AllowedPattern": "^[0-9a-zA-Z-/]*$",
"ConstraintDescription": "Quick Start key prefix can include numbers, lowercase letters, uppercase letters, hyphens (-), and forward slash (/).",
Expand Down Expand Up @@ -253,7 +259,7 @@
},
"WorkloadNodesDesiredCapacity": {
"Default": "2",
"Description": "Desired capacity for the Workload nodes Auto Scaling group.",
"Description": "Desired capacity for the workload nodes Auto Scaling group.",
"Type": "String"
},
"WorkloadNodesMaxSize": {
Expand All @@ -267,12 +273,48 @@
"Type": "String"
}
},
"Conditions": {
"UsingDefaultBucket": {
"Fn::Equals": [
{
"Ref": "QSS3BucketName"
},
"aws-quickstart"
]
}
},
"Resources": {
"VPCStack": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": {
"Fn::Sub": "https://${QSS3BucketName}.s3.amazonaws.com/${QSS3KeyPrefix}submodules/quickstart-aws-vpc/templates/aws-vpc.template"
"Fn::Sub": [
"https://${S3Bucket}.s3.${S3Region}.${AWS::URLSuffix}/${QSS3KeyPrefix}submodules/quickstart-aws-vpc/templates/aws-vpc.template",
{
"S3Region": {
"Fn::If": [
"UsingDefaultBucket",
{
"Ref": "AWS::Region"
},
{
"Ref": "QSS3BucketRegion"
}
]
},
"S3Bucket": {
"Fn::If": [
"UsingDefaultBucket",
{
"Fn::Sub": "${QSS3BucketName}-${AWS::Region}"
},
{
"Ref": "QSS3BucketName"
}
]
}
}
]
},
"Parameters": {
"AvailabilityZones": {
Expand Down Expand Up @@ -310,9 +352,44 @@
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": {
"Fn::Sub": "https://${QSS3BucketName}.s3.amazonaws.com/${QSS3KeyPrefix}submodules/quickstart-linux-bastion/templates/linux-bastion.template"
"Fn::Sub": [
"https://${S3Bucket}.s3.${S3Region}.${AWS::URLSuffix}/${QSS3KeyPrefix}submodules/quickstart-linux-bastion/templates/linux-bastion.template",
{
"S3Region": {
"Fn::If": [
"UsingDefaultBucket",
{
"Ref": "AWS::Region"
},
{
"Ref": "QSS3BucketRegion"
}
]
},
"S3Bucket": {
"Fn::If": [
"UsingDefaultBucket",
{
"Fn::Sub": "${QSS3BucketName}-${AWS::Region}"
},
{
"Ref": "QSS3BucketName"
}
]
}
}
]
},
"Parameters": {
"QSS3BucketName": {
"Ref": "QSS3BucketName"
},
"QSS3BucketRegion": {
"Ref": "QSS3BucketRegion"
},
"QSS3KeyPrefix": {
"Sub": "${QSS3KeyPrefix}submodules/quickstart-linux-bastion/"
},
"BastionAMIOS": {
"Ref": "BastionAMIOS"
},
Expand All @@ -334,12 +411,6 @@
"Outputs.PublicSubnet2ID"
]
},
"QSS3BucketName": {
"Ref": "QSS3BucketName"
},
"QSS3KeyPrefix": {
"Fn::Sub": "${QSS3KeyPrefix}submodules/quickstart-linux-bastion/"
},
"RemoteAccessCIDR": {
"Ref": "RemoteAccessCIDR"
},
Expand All @@ -357,7 +428,33 @@
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": {
"Fn::Sub": "https://${QSS3BucketName}.s3.amazonaws.com/${QSS3KeyPrefix}templates/workload-json.template"
"Fn::Sub": [
"https://${S3Bucket}.s3.${S3Region}.${AWS::URLSuffix}/${QSS3KeyPrefix}templates/workload-yaml.template",
{
"S3Region": {
"Fn::If": [
"UsingDefaultBucket",
{
"Ref": "AWS::Region"
},
{
"Ref": "QSS3BucketRegion"
}
]
},
"S3Bucket": {
"Fn::If": [
"UsingDefaultBucket",
{
"Fn::Sub": "${QSS3BucketName}-${AWS::Region}"
},
{
"Ref": "QSS3BucketName"
}
]
}
}
]
},
"Parameters": {
"WorkloadInstanceType": {
Expand Down Expand Up @@ -411,6 +508,9 @@
"QSS3BucketName": {
"Ref": "QSS3BucketName"
},
"QSS3BucketRegion": {
"Ref": "QSS3BucketRegion"
},
"QSS3KeyPrefix": {
"Ref": "QSS3KeyPrefix"
},
Expand All @@ -427,4 +527,4 @@
}
}
}
}
}
104 changes: 44 additions & 60 deletions templates/workload-json.template
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
},
"Parameters": [
"QSS3BucketName",
"QSS3BucketRegion",
"QSS3KeyPrefix"
]
}
Expand Down Expand Up @@ -80,6 +81,9 @@
"QSS3BucketName": {
"default": "Quick Start S3 bucket name"
},
"QSS3BucketRegion": {
"default": "Quick Start S3 bucket region"
},
"QSS3KeyPrefix": {
"default": "Quick Start S3 key prefix"
},
Expand Down Expand Up @@ -142,6 +146,11 @@
"Description": "S3 bucket name for the Quick Start assets. This string can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-).",
"Type": "String"
},
"QSS3BucketRegion": {
"Default": "us-east-1",
"Description": "The AWS Region where the Quick Start S3 bucket (QSS3BucketName) is hosted. When using your own bucket, you must specify this value.",
"Type": "String"
},
"QSS3KeyPrefix": {
"AllowedPattern": "^[0-9a-zA-Z-/]*$",
"ConstraintDescription": "Quick Start key prefix can include numbers, lowercase letters, uppercase letters, hyphens (-), and forward slash (/).",
Expand Down Expand Up @@ -191,7 +200,7 @@
},
"WorkloadNodesDesiredCapacity": {
"Default": "2",
"Description": "Desired capacity for the Workload nodes Auto Scaling group.",
"Description": "Desired capacity for the workload nodes Auto Scaling group.",
"Type": "String"
},
"WorkloadNodesMaxSize": {
Expand Down Expand Up @@ -295,6 +304,16 @@
}
}
},
"Conditions": {
"UsingDefaultBucket": {
"Fn::Equals": [
{
"Ref": "QSS3BucketName"
},
"aws-quickstart"
]
}
},
"Resources": {
"NotificationTopic": {
"Type": "AWS::SNS::Topic",
Expand Down Expand Up @@ -402,9 +421,26 @@
"Action": [
"s3:GetObject"
],
"Resource": {
"Fn::Sub": "arn:aws:s3:::${QSS3BucketName}/${QSS3KeyPrefix}*"
},
"Resource": [
{
"Fn::Sub": [
"arn:${AWS::Partition}:s3:::${S3Bucket}/${QSS3KeyPrefix}*",
{
"S3Bucket": {
"Fn::If": [
"UsingDefaultBucket",
{
"Fn::Sub": "${QSS3BucketName}-${AWS::Region}"
},
{
"Ref": "QSS3BucketName"
}
]
}
}
]
}
],
"Effect": "Allow"
}
]
Expand All @@ -431,28 +467,10 @@
],
"Resource": [
{
"Fn::Join": [
"",
[
"arn:aws:s3:::",
{
"Ref": "S3Bucket"
},
""
]
]
"Fn::Sub": "arn:aws:s3:::${S3Bucket}"
},
{
"Fn::Join": [
"",
[
"arn:aws:s3:::",
{
"Ref": "S3Bucket"
},
"/*"
]
]
"Fn::Sub": "arn:aws:s3:::${S3Bucket}/*"
}
]
}
Expand Down Expand Up @@ -551,41 +569,7 @@
],
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"#!/bin/bash\n",
"export PATH=$PATH:/usr/local/bin\n",
"which pip &> /dev/null\n",
"if [ $? -ne 0 ] ; then\n",
" echo \"PIP NOT INSTALLED\"\n",
" [ `which yum` ] && $(yum install -y epel-release; yum install -y python-pip) && echo \"PIP INSTALLED\"\n",
" [ `which apt-get` ] && apt-get -y update && apt-get -y install python-pip && echo \"PIP INSTALLED\"\n",
"fi\n",
"pip install --upgrade pip &> /dev/null\n",
"pip install awscli --ignore-installed six &> /dev/null\n",
"easy_install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n",
"cfn-init --stack ",
{
"Ref": "AWS::StackName"
},
" --resource WorkloadASLaunchConfig --configsets quickstart --region ",
{
"Ref": "AWS::Region"
},
"\n",
"# Signal the status from cfn-init\n",
"cfn-signal -e $? --stack ",
{
"Ref": "AWS::StackName"
},
" --resource WorkloadAutoScalingGroup --region ",
{
"Ref": "AWS::Region"
},
"\n"
]
]
"Fn::Sub": "#!/bin/bash\nexport PATH=$PATH:/usr/local/bin\nwhich pip &> /dev/null\nif [ $? -ne 0 ] ; then\n echo \"PIP NOT INSTALLED\"\n [ `which yum` ] && $(yum install -y epel-release; yum install -y python-pip) && echo \"PIP INSTALLED\"\n [ `which apt-get` ] && apt-get -y update && apt-get -y install python-pip && echo \"PIP INSTALLED\"\nfi\npip install --upgrade pip &> /dev/null\npip install awscli --ignore-installed six &> /dev/null\neasy_install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\ncfn-init --stack ${AWS::StackName} --resource WorkloadASLaunchConfig --configsets quickstart --region ${AWS::Region}\n# Signal the status from cfn-init\ncfn-signal -e $? --stack ${AWS::StackName} --resource WorkloadAutoScalingGroup --region ${AWS::Region}\n"
}
}
}
Expand Down Expand Up @@ -745,4 +729,4 @@
}
}
}
}
}
Loading

0 comments on commit d9609cb

Please sign in to comment.