This repository has been archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy path06_conditions.yml
43 lines (37 loc) · 1.59 KB
/
06_conditions.yml
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
AWSTemplateFormatVersion: "2010-09-09"
Description: "RDS instance for various environments"
Parameters:
Environment:
Type: String
AllowedValues:
- dev
- stage
- prod
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html
Conditions:
CreateProdResources: !Equals [ !Ref Environment, prod ] # yaml shorthand could be confusing (!=)
CreateProdResourcesUsEast1: !And
- !Equals [!Ref AWS::Region, "us-east-1"]
- !Condition CreateProdResources
# !Equals
# Fn::Equals:
Resources:
RdsDbInstance:
Type: "AWS::RDS::DBInstance"
DeletionPolicy: !If [CreateProdResources, "Snapshot", AWS::NoValue]
Properties:
AllocatedStorage: !If [CreateProdResources, 100, 10] # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html
AllowMajorVersionUpgrade: false
AutoMinorVersionUpgrade: true
BackupRetentionPeriod: !If [CreateProdResources, 35, 5]
DBClusterIdentifier: myDBCluster # reminder: see update requires replacement
DBInstanceClass: !If [CreateProdResources, "db.m5.2xlarge", "db.m5.large"]
Engine: postgres # https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html
EngineVersion: 9.6.6
Iops: !If [CreateProdResources, 3000, 1000]
MultiAZ: !Condition CreateProdResources
StorageEncrypted: !Condition CreateProdResources # https://github.com/awsdocs/aws-cloudformation-user-guide/issues/3
StorageType: io1
Tags:
- Name: Environment
Value: !Ref Environment