-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcf-template.yaml
70 lines (59 loc) · 1.57 KB
/
cf-template.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
AWSTemplateFormatVersion: 2010-09-09
Parameters:
SelectStage:
Type: String
AllowedValues:
- dev
- stage
- prod
ConstraintDescription: must specify prod, dev, or stage.
S3BucketName:
Type: String
AllowedPattern: '(?!(^xn--|.+-s3alias$))^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$'
ConstraintDescription: ' Incorrect bucket naming convention'
Mappings:
EnvMap:
dev:
InstanceType : "t2.micro"
name: 'dev setup'
stage:
InstanceType : "t2.small"
name: 'stage setup'
prod:
InstanceType : "t2.large"
name: 'prod setup'
Conditions:
CreateProdResources: !Equals [!Ref SelectStage, prod]
Resources:
EC2Instance:
Type: AWS::EC2::Instance
Properties:
InstanceType: !FindInMap [EnvMap, !Ref "SelectStage", InstanceType]
ImageId: ami-09d3b3274b6c5d4aa
Tags:
- Key: 'name'
Value: !FindInMap [EnvMap, !Ref "SelectStage", name]
MountPoint:
Type: "AWS::EC2::VolumeAttachment"
Condition: CreateProdResources
Properties:
InstanceId: !Ref EC2Instance
VolumeId: !Ref NewVolume
Device: /dev/sdh
NewVolume:
Type: "AWS::EC2::Volume"
Condition: CreateProdResources
Properties:
Size: 100
AvailabilityZone: !GetAtt EC2Instance.AvailabilityZone
CreateS3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref S3BucketName
Outputs:
EC2Instance:
Value: !Ref 'EC2Instance'
Description: 'EC2 instance create'
BucketName:
Value: !Ref 'CreateS3Bucket'
Description: Name of the Amazon S3 bucket