Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
feat(contrib/ec2): use absolute path names for scripts
Browse files Browse the repository at this point in the history
This enables users to run the AWS provision script from any directory.
  • Loading branch information
carmstrong committed Dec 29, 2014
1 parent 41d1cc9 commit 6db1e50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions contrib/ec2/gen-json.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import yaml

template = json.load(open("deis.template.json",'r'))
CURR_DIR = os.path.dirname(os.path.realpath(__file__))

# Add EC2-specific units to the shared user-data
FORMAT_EPHEMERAL = '''
Expand All @@ -29,13 +29,15 @@
Type=btrfs
'''

data = yaml.load(file('../coreos/user-data', 'r'))
data = yaml.load(file(os.path.join(CURR_DIR, '..', 'coreos', 'user-data'), 'r'))
data['coreos']['units'].append(dict({'name': 'format-ephemeral.service', 'command': 'start', 'content': FORMAT_EPHEMERAL}))
data['coreos']['units'].append(dict({'name': 'var-lib-docker.mount', 'command': 'start', 'content': DOCKER_MOUNT}))

header = ["#cloud-config", "---"]
dump = yaml.dump(data, default_flow_style=False)

template = json.load(open(os.path.join(CURR_DIR, 'deis.template.json'),'r'))

template['Resources']['CoreOSServerLaunchConfig']['Properties']['UserData']['Fn::Base64']['Fn::Join'] = [ "\n", header + dump.split("\n") ]
template['Parameters']['ClusterSize']['Default'] = str(os.getenv('DEIS_NUM_INSTANCES', 3))

Expand Down
4 changes: 2 additions & 2 deletions contrib/ec2/provision-ec2-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ $CONTRIB_DIR/util/check-user-data.sh

# create an EC2 cloudformation stack based on CoreOS's default template
aws cloudformation create-stack \
--template-body "$(./gen-json.py)" \
--template-body "$($THIS_DIR/gen-json.py)" \
--stack-name $NAME \
--parameters "$(<cloudformation.json)"
--parameters "$(<$THIS_DIR/cloudformation.json)"

echo_green "Your Deis cluster has successfully deployed to AWS CloudFormation."
echo_green "Please continue to follow the instructions in the README."

0 comments on commit 6db1e50

Please sign in to comment.