Skip to content

Commit 6db1e50

Browse files
committed
feat(contrib/ec2): use absolute path names for scripts
This enables users to run the AWS provision script from any directory.
1 parent 41d1cc9 commit 6db1e50

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

contrib/ec2/gen-json.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import yaml
55

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

88
# Add EC2-specific units to the shared user-data
99
FORMAT_EPHEMERAL = '''
@@ -29,13 +29,15 @@
2929
Type=btrfs
3030
'''
3131

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

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

39+
template = json.load(open(os.path.join(CURR_DIR, 'deis.template.json'),'r'))
40+
3941
template['Resources']['CoreOSServerLaunchConfig']['Properties']['UserData']['Fn::Base64']['Fn::Join'] = [ "\n", header + dump.split("\n") ]
4042
template['Parameters']['ClusterSize']['Default'] = str(os.getenv('DEIS_NUM_INSTANCES', 3))
4143

contrib/ec2/provision-ec2-cluster.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ $CONTRIB_DIR/util/check-user-data.sh
4040

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

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

0 commit comments

Comments
 (0)