Skip to content

Commit 5f0327c

Browse files
committed
- Changing line endings for the bash script
- Adding editorconfig to try to help with line endings - Added shebang so script will execute
1 parent 87f1240 commit 5f0327c

File tree

3 files changed

+68
-10
lines changed

3 files changed

+68
-10
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true

scripts/mongoanddockerinit.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/bash
12
USERNAME=""
23
PASSWORD=""
34

@@ -33,7 +34,13 @@ sudo mkdir -p /data/db
3334
sudo mount /dev/xvdh /data/db
3435

3536
# Setup the repository for installing mongo
36-
echo "[mongodb-org-3.2]\nname=MongoDB Repository\nbaseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.2/x86_64/\ngpgcheck=1\nenabled=1\ngpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc\n" > /etc/yum.repos.d/mongodb-org-3.2.repo
37+
echo "[mongodb-org-3.2]
38+
name=MongoDB Repository
39+
baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.2/x86_64/
40+
gpgcheck=1
41+
enabled=1
42+
gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc
43+
" > /etc/yum.repos.d/mongodb-org-3.2.repo
3744
sudo yum -y update
3845
# Install mongo server, shell and tools
3946
sudo yum install -y mongodb-org-server mongodb-org-shell mongodb-org-tools

templates/mongoanddocker.template

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@
4141
},
4242
"DbAdminUsername": {
4343
"Description": "Username for the admin user of the database",
44-
"Type": "String"
44+
"Type": "String"
4545
},
4646
"DbAdminPassword": {
4747
"Description": "Password for the admin user of the database",
48-
"Type": "String"
48+
"Type": "String",
49+
"NoEcho": true
4950
}
5051
},
5152
"Conditions": {
@@ -127,7 +128,48 @@
127128
}
128129
}
129130
},
130-
"Resources": {
131+
"Resources": {
132+
"EC2InstanceRole": {
133+
"Type": "AWS::IAM::Role",
134+
"Properties": {
135+
"AssumeRolePolicyDocument": {
136+
"Version" : "2012-10-17",
137+
"Statement": [ {
138+
"Effect": "Allow",
139+
"Principal": {
140+
"Service": [ "ec2.amazonaws.com" ]
141+
},
142+
"Action": [ "sts:AssumeRole" ]
143+
} ]
144+
},
145+
"Policies": [
146+
{
147+
"PolicyName": "MongoAndDockerInstancePolicy",
148+
"PolicyDocument": {
149+
"Version": "2012-10-17",
150+
"Statement": [
151+
{
152+
"Effect": "Allow",
153+
"Action": [
154+
"s3:Get*",
155+
"s3:List*"
156+
],
157+
"Resource": "*"
158+
}
159+
]
160+
}
161+
}
162+
]
163+
}
164+
},
165+
"EC2InstanceProfile": {
166+
"Type": "AWS::IAM::InstanceProfile",
167+
"Properties":{
168+
"Roles": [
169+
{ "Ref": "EC2InstanceRole" }
170+
]
171+
}
172+
},
131173
"NewSecurityGroup": {
132174
"Type": "AWS::EC2::SecurityGroup",
133175
"Condition": "CreateNewSecurityGroup",
@@ -151,6 +193,7 @@
151193
"InstanceType": {
152194
"Ref": "InstanceType"
153195
},
196+
"IamInstanceProfile": { "Ref": "EC2InstanceProfile" },
154197
"SecurityGroups": [
155198
"SSH from home"
156199
],
@@ -180,14 +223,13 @@
180223
"#!/bin/bash -xe\n",
181224
"sudo yum -y update\n",
182225
"sudo yum install -y git\n",
183-
"git config --global user.name lukewis\n",
184-
"git config --global user.email [email protected]\n",
185-
"git clone https://github.com/lukewis/aws.git\n",
186-
"./aws/scripts/mongoanddockerinit.sh -u ",
226+
"mkdir -p /aws/scripts/\n",
227+
"aws s3 cp s3://com.figtreesoftware.cf.scripts/mongoanddockerinit.sh /aws/scripts/mongoanddockerinit.sh\n",
228+
"sudo chmod +x /aws/scripts/mongoanddockerinit.sh\n",
229+
"/aws/scripts/mongoanddockerinit.sh -u ",
187230
{ "Ref" : "DbAdminUsername" },
188231
" -p ",
189-
{ "Ref" : "DbAdminPassword" },
190-
"\n"
232+
{ "Ref" : "DbAdminPassword" }
191233
]]
192234
}
193235
}

0 commit comments

Comments
 (0)