-
Notifications
You must be signed in to change notification settings - Fork 19
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
+98
−62
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
544d18b
update cmft templates with stackrefs
deathtenk 915d4d1
readded CORS config stuff
deathtenk 0e3302e
made VPCId and DBSubnets optional parameters
deathtenk 469608f
fixed missing comma in launch script
deathtenk 1a9d2f8
updated DBSubnets condition with list
deathtenk aeaebef
fixed broken params in templates
deathtenk c806516
added information to VPCStackName doc string
deathtenk 934c4dc
fixed db version to 12.9
deathtenk 3c7f48d
removed stackrefs for VPC
deathtenk 33bd462
removed stackrefs for vpc resources on 2_lrs
deathtenk f73b9d4
made DBMassterUserPasswordPath a ref
deathtenk 2a4a068
removed unecessary instructions from docs
deathtenk 127046c
formatting fixes
deathtenk 6dea98f
more formatting fixes
deathtenk 37205e0
updated doc strings
deathtenk 867614e
added DBStackName to docs
deathtenk 8c33026
added InstanceSubnets as own param
deathtenk 9e1f69c
Merge branch 'main' into stackref_update
deathtenk f4112ab
set dbdeletion default to true
deathtenk c2acf07
reverted default db instance type to r4.large
deathtenk e0d190c
removed default DBStackName
deathtenk 84a3fd8
updated docs on DBSubnets
deathtenk 8c3944b
removed text fragment from cors stuff
deathtenk 0347f18
Merge branch 'main' into stackref_update
deathtenk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,20 @@ | ||
AWSTemplateFormatVersion: "2010-09-09" | ||
Description: "SQL LRS and DB Init Script" | ||
Parameters: | ||
# Networking | ||
VPCId: | ||
Description: "VPC on which to run SQL LRS" | ||
Description: VPC on which to run SQL LRS | ||
Type: AWS::EC2::VPC::Id | ||
DBSubnets: | ||
Description: Subnets on which the DB is running | ||
Type: List<AWS::EC2::Subnet::Id> | ||
# DB Details | ||
DBName: | ||
Description: PG Database name. Ignored if DBSnapshotIdentifier is provided | ||
DBStackName: | ||
Description: DB Stack Reference | ||
Type: String | ||
Default: "lrsql_demo" | ||
DBHost: | ||
Description: Write hostname of PG db | ||
Type: String | ||
DBPort: | ||
Description: Port of PG db | ||
Type: String | ||
Default: 3306 | ||
DBInstanceSG: | ||
Type: AWS::EC2::SecurityGroup::Id | ||
Description: DB instance security group | ||
DBMasterUserName: | ||
Description: Name of admin user | ||
Type: String | ||
Default: yetadmin | ||
DBAppUserName: | ||
Description: Name of app db user | ||
Type: String | ||
Default: lrsqldbuser | ||
DBMasterUserPasswordPath: | ||
Description: SSM Path to the secret password | ||
Type: String | ||
Default: "/lrsql/demo/DB_MASTER_USER_PASSWORD" | ||
DBMasterUserPasswordVersion: | ||
Description: SSM version | ||
Type: Number | ||
Default: 1 | ||
DBAppUserPasswordPath: | ||
Description: SSM Path to the secret password | ||
Type: String | ||
|
@@ -77,7 +53,7 @@ Parameters: | |
InstanceSSHCidr: | ||
Description: CIDR Range for SSH Access to instances (Typically VPC CIDR Range) | ||
Type: String | ||
Default: "173.147.0.0/16" | ||
Default: "172.147.0.0/16" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i sorta get updating these but in general its totally deployment specific. |
||
InstanceSubnets: | ||
Description: Subnet on which to run the lrsql server | ||
Type: List<AWS::EC2::Subnet::Id> | ||
|
@@ -112,28 +88,27 @@ Parameters: | |
ASGCPUPolicyTargetValue: | ||
Type: String # according to docs a Double | ||
Description: Target CPU utilization of instances. Leave blank to disable CPU autoscaling. | ||
Default: "" # '60.0' | ||
Default: "" # "60.0" | ||
ASGALBRequestCountTargetValue: | ||
Type: String # according to docs a Double | ||
Description: Target requests per instance. Leave blank to disable request count autoscaling. | ||
Default: "" # '10000.0' | ||
Default: "" # "10000.0" | ||
|
||
# Front-end (ALB) specific settings | ||
ALBSubnets: | ||
Description: Subnets on which to run the ALB. | ||
Type: List<AWS::EC2::Subnet::Id> | ||
ALBHostName: | ||
Type: String | ||
Description: The hostname to use for the Elastic Load Balancer. | ||
Default: "sqllrs.yetanalytics.io" | ||
ALBSubnets: | ||
Description: Subnets that are used by the Elastic Load Balancer. | ||
Type: List<AWS::EC2::Subnet::Id> | ||
ALBCertArn: | ||
Type: String | ||
Description: The ARN of an ACM cert to use on the ALB | ||
ALBHostedZone: | ||
Type: String | ||
Description: Route53 Hosted Zone in which to set a DNS record. If unset no record will be updated | ||
Default: "" | ||
|
||
# CORS Settings | ||
CORSAllowedOrigins: | ||
Type: CommaDelimitedList | ||
|
@@ -157,7 +132,8 @@ Conditions: | |
!Not [!Equals [!Ref ASGCPUPolicyTargetValue, ""]] | ||
ASGALBRequestCountTargetValueProvided: | ||
!Not [!Equals [!Ref ASGALBRequestCountTargetValue, ""]] | ||
InstanceKeyNameProvided: !Not [!Equals [!Ref InstanceKeyName, ""]] | ||
InstanceKeyNameProvided: | ||
!Not [!Equals [!Ref InstanceKeyName, ""]] | ||
|
||
Resources: | ||
# DB Initialization Function and custom resource to run it | ||
|
@@ -190,10 +166,15 @@ Resources: | |
Type: AWS::EC2::SecurityGroupIngress | ||
Properties: | ||
Description: Ingress from the init fn to RDS instance | ||
GroupId: !Ref DBInstanceSG | ||
GroupId: | ||
Fn::ImportValue: !Join [":", [!Ref "DBStackName", "DBInstanceSG"]] | ||
IpProtocol: tcp | ||
FromPort: !Ref DBPort | ||
ToPort: !Ref DBPort | ||
FromPort: | ||
Fn::ImportValue: | ||
!Join [":", [!Ref "DBStackName", "DBPort"]] | ||
ToPort: | ||
Fn::ImportValue: | ||
!Join [":", [!Ref "DBStackName", "DBPort"]] | ||
SourceSecurityGroupId: !Ref DBInitFnSG | ||
|
||
DBInitPolicy: | ||
|
@@ -211,7 +192,11 @@ Resources: | |
- "secretsmanager:GetSecretValue" | ||
Resource: | ||
- !Sub "arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter${DBAppUserPasswordPath}" | ||
- !Sub "arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter${DBMasterUserPasswordPath}" | ||
- !Sub | ||
- "arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter${DBMasterUserPasswordPath}" | ||
- DBMasterUserPasswordPath: | ||
Fn::ImportValue: | ||
!Join [":", [!Ref "DBStackName", "DBMasterUserPasswordPath"]] | ||
- Effect: Allow | ||
Action: | ||
- ec2:DescribeNetworkInterfaces | ||
|
@@ -241,19 +226,26 @@ Resources: | |
DependsOn: DBInitFn | ||
Properties: | ||
ServiceToken: !GetAtt DBInitFn.Arn | ||
DBMasterUsername: !Ref DBMasterUserName | ||
DBMasterUsername: | ||
Fn::ImportValue: !Join [":", [!Ref "DBStackName", "DBMasterUserName"]] | ||
DBMasterPasswordPath: !Join | ||
- ":" | ||
- - !Ref DBMasterUserPasswordPath | ||
- !Ref DBMasterUserPasswordVersion | ||
- - Fn::ImportValue: !Join [":", [!Ref "DBStackName", "DBMasterUserPasswordPath"]] | ||
- Fn::ImportValue: !Join [":", [!Ref "DBStackName", "DBMasterUserPasswordVersion"]] | ||
DBUsername: !Ref DBAppUserName | ||
DBPasswordPath: !Join | ||
- ":" | ||
- - !Ref DBAppUserPasswordPath | ||
- !Ref DBAppUserPasswordVersion | ||
DBHost: !Ref DBHost | ||
DBPort: !Ref DBPort | ||
DBName: !Ref DBName | ||
DBHost: | ||
Fn::ImportValue: | ||
!Join [":", [!Ref "DBStackName", "DBEndpoint"]] | ||
DBPort: | ||
Fn::ImportValue: | ||
!Join [":", [!Ref "DBStackName", "DBPort"]] | ||
DBName: | ||
Fn::ImportValue: | ||
!Join [":", [!Ref "DBStackName", "DBName"]] | ||
|
||
# Servers | ||
LogGroup: | ||
|
@@ -344,10 +336,15 @@ Resources: | |
Type: AWS::EC2::SecurityGroupIngress | ||
Properties: | ||
Description: Ingress from the LRS instance to RDS instance | ||
GroupId: !Ref DBInstanceSG | ||
GroupId: | ||
Fn::ImportValue: !Join [":", [!Ref "DBStackName", "DBInstanceSG"]] | ||
IpProtocol: tcp | ||
FromPort: !Ref DBPort | ||
ToPort: !Ref DBPort | ||
FromPort: | ||
Fn::ImportValue: | ||
!Join [":", [!Ref "DBStackName", "DBPort"]] | ||
ToPort: | ||
Fn::ImportValue: | ||
!Join [":", [!Ref "DBStackName", "DBPort"]] | ||
SourceSecurityGroupId: !Ref InstanceSG | ||
|
||
LrsInstances: | ||
|
@@ -499,7 +496,7 @@ Resources: | |
"dbPort": ${DBPort}, | ||
"dbName": "${DBName}", | ||
"dbUser": "${DBAppUserName}", | ||
"dbPassword": "${InitDBCustomResource.dbAppPass}" | ||
"dbPassword": "${DBPass}" | ||
}, | ||
"lrs" : { | ||
"adminUserDefault": "${DefaultAdminUser}", | ||
|
@@ -512,7 +509,18 @@ Resources: | |
"allowedOrigins": ${AllowedOrigins} | ||
} | ||
} | ||
- AllowedOrigins: !If | ||
- DBName: | ||
Fn::ImportValue: !Join [":", [!Ref "DBStackName", "DBName"]] | ||
DBHost: | ||
Fn::ImportValue: !Join [":", [!Ref "DBStackName", "DBEndpoint"]] | ||
DBAppUserName: !Ref DBAppUserName | ||
DBPass: !GetAtt InitDBCustomResource.dbAppPass | ||
DefaultAdminUser: !Ref DefaultAdminUser | ||
DefaultAdminPass: !Ref DefaultAdminPass | ||
InstanceHttpPort: !Ref InstanceHttpPort | ||
DBPort: | ||
Fn::ImportValue: !Join [":", [!Ref "DBStackName", "DBPort"]] | ||
AllowedOrigins: !If | ||
- SetCORS | ||
- !Sub | ||
- '["${JoinedAllowedOrigins}"]' | ||
|
@@ -611,6 +619,7 @@ Resources: | |
- !GetAtt TargetGroup.TargetGroupFullName | ||
TargetValue: !Ref ASGALBRequestCountTargetValue | ||
|
||
|
||
# ASG | ||
AutoScalingGroup: | ||
Type: AWS::AutoScaling::AutoScalingGroup | ||
|
@@ -757,3 +766,5 @@ Outputs: | |
- "" | ||
- - "https://" | ||
- !Ref ALBHostName | ||
Export: | ||
Name: !Sub "${AWS::StackName}:LrsAddress" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neat!