-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest1Stack.yaml
More file actions
100 lines (89 loc) · 2.76 KB
/
Copy pathtest1Stack.yaml
File metadata and controls
100 lines (89 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
AWSTemplateFormatVersion: "2010-09-09"
Metadata:
Generator: "former2"
Description: ""
Parameters:
AMI:
Description: OS Golden Image
Type: String
Default: "ami-0b5eea76982371e91"
Hardware:
Description: Hardware
Type: String
Default: "t2.micro"
SSHKey:
Description: SSH Key Pair
Type: String
Default: "ec2-user"
UserData:
Description: Boot time actions
Type: String
Default: |
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
#
# This part is done only once, just after launching of the instance
#
#package_update: true
#package_upgrade: true
#package_reboot_if_required: true
power_state:
delay: now
mode: poweroff
message: Powering off
timeout: 2
condition: true
#runcmd:
# - [ sh, -c, 'echo "Here is a line of text to log"' ]
# - touch /tmp/i_actually_ran.txt
#
# This part ensures that the final part runs on every boot
#
cloud_final_modules:
- [scripts-user, always]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
#
# This part is done on every, single boot
#
ls -1 /etc/ssh/*key | xargs -i ssh-keygen -l -f {}
--//--
Resources:
EC2Instance:
Type: "AWS::EC2::Instance"
Properties:
ImageId: !Ref AMI
InstanceType: !Ref Hardware
KeyName: !Ref SSHKey
AvailabilityZone: !Sub "${AWS::Region}a"
UserData:
Fn::Base64:
!Ref UserData
Tags:
-
Key: "Name"
Value: "test1"
EC2Instance2:
Type: "AWS::EC2::Instance"
Properties:
ImageId: !Ref AMI
InstanceType: !Ref Hardware
KeyName: !Ref SSHKey
AvailabilityZone: !Sub "${AWS::Region}b"
UserData:
Fn::Base64:
!Ref UserData
Tags:
-
Key: "Name"
Value: "test2"