This repository has been archived by the owner on Feb 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
/
ec2-yum-update.yaml
80 lines (80 loc) · 1.98 KB
/
ec2-yum-update.yaml
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
---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'AWS in Action: chapter 6 (IAM role)'
Parameters:
KeyName:
Description: 'Key Pair name'
Type: 'AWS::EC2::KeyPair::KeyName'
Default: mykey
VPC:
Description: 'Just select the one and only default VPC'
Type: 'AWS::EC2::VPC::Id'
Subnet:
Description: 'Just select one of the available subnets'
Type: 'AWS::EC2::Subnet::Id'
Mappings:
RegionMap:
'ap-south-1':
AMI: 'ami-2ed19c41'
'eu-west-3':
AMI: 'ami-c8a017b5'
'eu-west-2':
AMI: 'ami-e3051987'
'eu-west-1':
AMI: 'ami-760aaa0f'
'ap-northeast-2':
AMI: 'ami-fc862292'
'ap-northeast-1':
AMI: 'ami-2803ac4e'
'sa-east-1':
AMI: 'ami-1678037a'
'ca-central-1':
AMI: 'ami-ef3b838b'
'ap-southeast-1':
AMI: 'ami-dd7935be'
'ap-southeast-2':
AMI: 'ami-1a668878'
'eu-central-1':
AMI: 'ami-e28d098d'
'us-east-1':
AMI: 'ami-6057e21a'
'us-east-2':
AMI: 'ami-aa1b34cf'
'us-west-1':
AMI: 'ami-1a033c7a'
'us-west-2':
AMI: 'ami-32d8124a'
Resources:
SecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupDescription: 'My security group'
VpcId: !Ref VPC
SecurityGroupIngress:
- CidrIp: '0.0.0.0/0'
FromPort: 22
IpProtocol: tcp
ToPort: 22
Tags:
- Key: Name
Value: 'AWS in Action: chapter 6 (IAM role)'
Instance:
Type: 'AWS::EC2::Instance'
Properties:
ImageId: !FindInMap [RegionMap, !Ref 'AWS::Region', AMI]
InstanceType: 't2.micro'
KeyName: !Ref KeyName
SecurityGroupIds:
- !Ref SecurityGroup
SubnetId: !Ref Subnet
Tags:
- Key: Name
Value: 'AWS in Action: chapter 6 (yum update)'
UserData:
'Fn::Base64': |
#!/bin/bash -x
yum -y update
Outputs:
InstancePublicName:
Value: !Sub ${Instance.PublicDnsName}
Description: Public name (connect via SSH as user ec2-user)