Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update cmft templates with stackrefs #276

Merged
merged 24 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
544d18b
update cmft templates with stackrefs
deathtenk Jan 27, 2023
915d4d1
readded CORS config stuff
deathtenk Jan 27, 2023
0e3302e
made VPCId and DBSubnets optional parameters
deathtenk Jan 27, 2023
469608f
fixed missing comma in launch script
deathtenk Jan 27, 2023
1a9d2f8
updated DBSubnets condition with list
deathtenk Jan 27, 2023
aeaebef
fixed broken params in templates
deathtenk Jan 27, 2023
c806516
added information to VPCStackName doc string
deathtenk Jan 27, 2023
934c4dc
fixed db version to 12.9
deathtenk Jan 27, 2023
3c7f48d
removed stackrefs for VPC
deathtenk Jan 31, 2023
33bd462
removed stackrefs for vpc resources on 2_lrs
deathtenk Jan 31, 2023
f73b9d4
made DBMassterUserPasswordPath a ref
deathtenk Jan 31, 2023
2a4a068
removed unecessary instructions from docs
deathtenk Jan 31, 2023
127046c
formatting fixes
deathtenk Jan 31, 2023
6dea98f
more formatting fixes
deathtenk Jan 31, 2023
37205e0
updated doc strings
deathtenk Jan 31, 2023
867614e
added DBStackName to docs
deathtenk Feb 1, 2023
8c33026
added InstanceSubnets as own param
deathtenk Feb 1, 2023
9e1f69c
Merge branch 'main' into stackref_update
deathtenk Feb 1, 2023
f4112ab
set dbdeletion default to true
deathtenk Feb 1, 2023
c2acf07
reverted default db instance type to r4.large
deathtenk Feb 1, 2023
e0d190c
removed default DBStackName
deathtenk Feb 1, 2023
84a3fd8
updated docs on DBSubnets
deathtenk Feb 1, 2023
8c3944b
removed text fragment from cors stuff
deathtenk Feb 1, 2023
0347f18
Merge branch 'main' into stackref_update
deathtenk Feb 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 38 additions & 10 deletions dev-resources/template/1_db.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
AWSTemplateFormatVersion: "2010-09-09"
Description: "Postgres DB for SQL LRS"
Parameters:
# Networking
VPCStackName:
Description: Name of VPC Stack (Optional, but if not provided must provide VPCId and DBSubnets).
Type: String
VPCId:
Description: "VPC on which to run SQL LRS"
Description: "VPC on which to run SQL LRS (if not provided, will attempt to use parameter VPC on VPCStackName)"
Type: AWS::EC2::VPC::Id
DBSubnets:
Description: Subnets on which to run services
Description: Subnets on which the DB is running (if no subnets are provided, will attempt to deploy with PrivateSubnetOne and PrivateSubnetTwo on the VPC provided via VPCStackName)
Type: List<AWS::EC2::Subnet::Id>

# Postgres
Expand All @@ -31,7 +33,7 @@ Parameters:
DBInstanceClass:
Description: For provisioned aurora, the instance class to use
Type: String
Default: "db.r4.large"
Default: "db.t4g.medium"
milt marked this conversation as resolved.
Show resolved Hide resolved
DBName:
Description: PG Database name. Ignored if DBSnapshotIdentifier is provided
Type: String
Expand All @@ -58,26 +60,42 @@ Parameters:
AllowedValues:
- true
- false
Default: true
Default: false
milt marked this conversation as resolved.
Show resolved Hide resolved

Conditions:
DBProvisioned: !Equals [!Ref DBEngineMode, "provisioned"]
DBSnapshotIdentifierProvided: !Not [!Equals [!Ref DBSnapshotIdentifier, ""]]
DBProvisioned:
!Equals [!Ref DBEngineMode, "provisioned"]
DBSnapshotIdentifierProvided:
!Not [!Equals [!Ref DBSnapshotIdentifier, ""]]
VPCIdProvided:
!Not [!Equals [!Ref VPCId, ""]]
DBSubnetsProvided:
!Not [!Equals [!Join ["", !Ref DBSubnets], ""]]

Resources:

# PostgreSQL Database
DBSubnetGroup:
Description: Subnet group to allow instance access to db
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription: SQL LRS App Instance Subnet Group
SubnetIds: !Ref DBSubnets
SubnetIds: !If
- DBSubnetsProvided
- !Ref DBSubnets
- - Fn::ImportValue:
!Join [":", [!Ref "VPCStackName", "PrivateSubnetOne"]]
- Fn::ImportValue:
!Join [":", [!Ref "VPCStackName", "PrivateSubnetTwo"]]

DBInstanceSG:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Access to RDS instances
VpcId: !Ref VPCId
VpcId: !If
- VPCIdProvided
- !Ref VPCId
- Fn::ImportValue: !Join [":", [!Ref "VPCStackName", "VPC"]]

DBCluster:
Description: PostgreSQL DB Cluster
Expand All @@ -99,7 +117,7 @@ Resources:
- DBSnapshotIdentifierProvided
- !Ref AWS::NoValue
- !Sub "{{resolve:ssm-secure:${DBMasterUserPasswordPath}:${DBMasterUserPasswordVersion}}}"
# DBClusterIdentifier: !Sub '${AWS::StackName}-db'
# DBClusterIdentifier: !Sub "${AWS::StackName}-db"
BackupRetentionPeriod: !If
- DBSnapshotIdentifierProvided
- !Ref AWS::NoValue
Expand Down Expand Up @@ -145,3 +163,13 @@ Outputs:
Value: !Ref DBInstanceSG
Export:
Name: !Sub "${AWS::StackName}:DBInstanceSG"
DBName:
Description: Name of the DB
Value: !Ref DBName
Export:
Name: !Sub "${AWS::StackName}:DBName"
DBMasterUserName:
Description: DB Master username
Value: !Ref DBMasterUserName
Export:
Name: !Sub "${AWS::StackName}:DBMasterUserName"
Loading