Skip to content

Commit e386c24

Browse files
fabiobmboersma
authored andcommitted
feat(contrib/aws): allow easier selection of CoreOS version
This change allows an AWS user to quickly switch the CoreOS version of the CloudFormation template. Should also help reduce the work needed by Deis maintainers.
1 parent 56b5860 commit e386c24

5 files changed

Lines changed: 16 additions & 14 deletions

File tree

contrib/aws/deis.template.json

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,7 @@
127127
},
128128

129129
"Mappings" : {
130-
"CoreOSAMIs" : {
131-
"eu-central-1" : { "PV" : "ami-fe6b52e3", "HVM" : "ami-f86b52e5" },
132-
"ap-northeast-1" : { "PV" : "ami-9ec1119e", "HVM" : "ami-9cc1119c" },
133-
"us-gov-west-1" : { "PV" : "ami-854828a6", "HVM" : "ami-874828a4" },
134-
"sa-east-1" : { "PV" : "ami-d9b839c4", "HVM" : "ami-d5b839c8" },
135-
"ap-southeast-2" : { "PV" : "ami-7985fc43", "HVM" : "ami-7b85fc41" },
136-
"ap-southeast-1" : { "PV" : "ami-d4033b86", "HVM" : "ami-da033b88" },
137-
"us-east-1" : { "PV" : "ami-c16583aa", "HVM" : "ami-c36583a8" },
138-
"us-west-2" : { "PV" : "ami-995f60a9", "HVM" : "ami-975f60a7" },
139-
"us-west-1" : { "PV" : "ami-877a92c3", "HVM" : "ami-857a92c1" },
140-
"eu-west-1" : { "PV" : "ami-e38cfc94", "HVM" : "ami-e18cfc96" }
141-
},
130+
"CoreOSAMIs" : {},
142131
"RootDevices" : {
143132
"HVM" : { "Name": "/dev/xvda" },
144133
"PV" : { "Name": "/dev/sda" }

contrib/aws/gen-json.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
#!/usr/bin/env python
2+
import argparse
23
import json
34
import os
5+
import urllib
46
import yaml
57

8+
parser = argparse.ArgumentParser()
9+
parser.add_argument('--channel', help='the CoreOS channel to use', default='stable')
10+
parser.add_argument('--version', help='the CoreOS version to use', default='current')
11+
args = vars(parser.parse_args())
12+
13+
amis = json.load(urllib.urlopen("http://%(channel)s.release.core-os.net/amd64-usr/%(version)s/coreos_production_ami_all.json" % args))
14+
615
CURR_DIR = os.path.dirname(os.path.realpath(__file__))
716

817
# Add AWS-specific units to the shared user-data
@@ -97,6 +106,7 @@
97106

98107
template['Resources']['CoreOSServerLaunchConfig']['Properties']['UserData']['Fn::Base64']['Fn::Join'] = [ "\n", header + dump.split("\n") ]
99108
template['Parameters']['ClusterSize']['Default'] = str(os.getenv('DEIS_NUM_INSTANCES', 3))
109+
template['Mappings']['CoreOSAMIs'] = dict(map(lambda n: (n['name'], dict(PV=n['pv'], HVM=n['hvm'])), amis['amis']))
100110

101111
VPC_ID = os.getenv('VPC_ID', None)
102112
VPC_SUBNETS = os.getenv('VPC_SUBNETS', None)

contrib/aws/provision-aws-cluster.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bailout() {
4949

5050
# create an AWS cloudformation stack based on CoreOS's default template
5151
aws cloudformation create-stack \
52-
--template-body "$($THIS_DIR/gen-json.py)" \
52+
--template-body "$($THIS_DIR/gen-json.py --channel $COREOS_CHANNEL --version $COREOS_VERSION)" \
5353
--stack-name $STACK_NAME \
5454
--parameters "$(<$THIS_DIR/cloudformation.json)" \
5555
$EXTRA_AWS_CLI_ARGS

contrib/aws/update-aws-cluster.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ $CONTRIB_DIR/util/check-user-data.sh
3232

3333
# update the AWS CloudFormation stack
3434
aws cloudformation update-stack \
35-
--template-body "$($THIS_DIR/gen-json.py)" \
35+
--template-body "$($THIS_DIR/gen-json.py --channel $COREOS_CHANNEL --version $COREOS_VERSION)" \
3636
--stack-name $NAME \
3737
--parameters "$(<$THIS_DIR/cloudformation.json)" \
3838
$EXTRA_AWS_CLI_ARGS

contrib/utils.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ function echo_red {
1111
function echo_green {
1212
echo -e "\033[0;32m$1\033[0m"
1313
}
14+
15+
COREOS_CHANNEL=${COREOS_CHANNEL:-stable}
16+
COREOS_VERSION=${COREOS_VERSION:-647.2.0}

0 commit comments

Comments
 (0)