Skip to content

Commit

Permalink
Patch through parameters for augury clickhouse
Browse files Browse the repository at this point in the history
  • Loading branch information
svevang committed Jun 12, 2024
1 parent 94b4e03 commit 2b21e52
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spire/templates/apps-300A.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Parameters:
SharedAuroraPostgresqlEndpoint: { Type: String }
SharedAuroraPostgresqlPort: { Type: String }
SharedPostgresqlClientSecurityGroupId: { Type: String }
SharedClickhouseEndpoint: { Type: String }
SharedClickhousePort: { Type: String }
CastlePostgresInstanceEndpointAddress: { Type: String }
CastlePostgresInstanceEndpointPort: { Type: String }
CastlePostgresClientSecurityGroupId: { Type: String }
Expand Down Expand Up @@ -99,6 +101,11 @@ Resources:
SharedAuroraPostgresqlEndpoint: !Ref SharedAuroraPostgresqlEndpoint
SharedAuroraPostgresqlPort: !Ref SharedAuroraPostgresqlPort
SharedPostgresqlClientSecurityGroupId: !Ref SharedPostgresqlClientSecurityGroupId
SharedClickhouseEndpoint: !Ref SharedClickhouseEndpoint
SharedClickhousePort: !Ref SharedClickhousePort
SharedClickhouseAuguryDatabase: !Sub /prx/${EnvironmentTypeAbbreviation}/Spire/Dovetail-Clickhouse/augury-database
SharedClickhouseAuguryPassword: !Sub /prx/${EnvironmentTypeAbbreviation}/Spire/Dovetail-Clickhouse/augury-password
SharedClickhouseAuguryUsername: !Sub /prx/${EnvironmentTypeAbbreviation}/Spire/Dovetail-Clickhouse/augury-username
CastlePostgresInstanceEndpointAddress: !Ref CastlePostgresInstanceEndpointAddress
CastlePostgresInstanceEndpointPort: !Ref CastlePostgresInstanceEndpointPort
CastlePostgresClientSecurityGroupId: !Ref CastlePostgresClientSecurityGroupId
Expand Down
25 changes: 25 additions & 0 deletions spire/templates/apps/augury.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ Parameters:
SharedAuroraPostgresqlEndpoint: { Type: String }
SharedAuroraPostgresqlPort: { Type: String }
SharedPostgresqlClientSecurityGroupId: { Type: String }
SharedClickhouseEndpoint: { Type: String }
SharedClickhousePort: { Type: String }
SharedClickhouseAuguryDatabase: { Type: AWS::SSM::Parameter::Value<String> }
SharedClickhouseAuguryPassword: { Type: AWS::SSM::Parameter::Value<String>, NoEcho: true }
SharedClickhouseAuguryUsername: { Type: AWS::SSM::Parameter::Value<String> }
CastlePostgresInstanceEndpointAddress: { Type: String }
CastlePostgresInstanceEndpointPort: { Type: String }
CastlePostgresClientSecurityGroupId: { Type: String }
Expand Down Expand Up @@ -332,6 +337,16 @@ Resources:
Value: !Ref AuguryHostname
- Name: AWS_DEFAULT_REGION
Value: !Ref AWS::Region
- Name: CLICKHOUSE_DATABASE
Value: !Ref SharedClickhouseAuguryDatabase
- Name: CLICKHOUSE_HOST
Value: !Ref SharedClickhouseEndpoint
- Name: CLICKHOUSE_PASSWORD
Value: !Ref SharedClickhouseAuguryPassword
- Name: CLICKHOUSE_PORT
Value: !Ref SharedClickhousePort
- Name: CLICKHOUSE_USER
Value: !Ref SharedClickhouseAuguryUsername
- Name: POSTGRES_HOST
Value: !Ref SharedAuroraPostgresqlEndpoint
- Name: POSTGRES_PORT
Expand Down Expand Up @@ -477,6 +492,16 @@ Resources:
Value: !Ref AuguryHostname
- Name: AWS_DEFAULT_REGION
Value: !Ref AWS::Region
- Name: CLICKHOUSE_DATABASE
Value: !Ref SharedClickhouseAuguryDatabase
- Name: CLICKHOUSE_HOST
Value: !Ref SharedClickhouseEndpoint
- Name: CLICKHOUSE_PASSWORD
Value: !Ref SharedClickhouseAuguryPassword
- Name: CLICKHOUSE_PORT
Value: !Ref SharedClickhousePort
- Name: CLICKHOUSE_USER
Value: !Ref SharedClickhouseAuguryUsername
- Name: POSTGRES_HOST
Value: !Ref SharedAuroraPostgresqlEndpoint
- Name: POSTGRES_PORT
Expand Down
3 changes: 3 additions & 0 deletions spire/templates/root.yml
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ Resources:
UpdateReplacePolicy: Delete
Properties:
Parameters:
AuguryDatabase: !Sub /prx/${EnvironmentTypeAbbreviation}/Spire/Dovetail-Clickhouse/augury-database
AuguryPassword: !Sub /prx/${EnvironmentTypeAbbreviation}/Spire/Dovetail-Clickhouse/augury-password
AuguryUsername: !Sub /prx/${EnvironmentTypeAbbreviation}/Spire/Dovetail-Clickhouse/augury-username
AuthorizedKeys: !Join [",", !Ref AuthorizedKeys]
EnvironmentType: !Ref EnvironmentType
GoogleStorageBucket: !Sub /prx/${EnvironmentTypeAbbreviation}/Spire/Dovetail-Clickhouse/google-storage-bucket
Expand Down
13 changes: 13 additions & 0 deletions spire/templates/shared-clickhouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Parameters:
GoogleStorageHmacKeySecret: { Type: AWS::SSM::Parameter::Value<String>, NoEcho: true }
NestedChangeSetScrubbingResourcesState: { Type: String }
RegionMode: { Type: String }
AuguryDatabase: { Type: AWS::SSM::Parameter::Value<String> }
AuguryPassword: { Type: AWS::SSM::Parameter::Value<String>, NoEcho: true }
AuguryUsername: { Type: AWS::SSM::Parameter::Value<String> }
RollupsDatabase: { Type: AWS::SSM::Parameter::Value<String> }
RollupsPassword: { Type: AWS::SSM::Parameter::Value<String>, NoEcho: true }
RollupsUsername: { Type: AWS::SSM::Parameter::Value<String> }
Expand Down Expand Up @@ -132,18 +135,28 @@ Resources:
# https://github.com/PRX/castlehouse/tree/main
command: !Sub |
#!/bin/bash
# Rollups
export DBNAME=${RollupsDatabase}
if test -z "$(clickhouse-client -d $DBNAME -q 'show tables')"; then
clickhouse-client -q "CREATE DATABASE $DBNAME"
clickhouse-client -d $DBNAME --queries-file <(curl -s https://raw.githubusercontent.com/PRX/castlehouse/main/schema/tables.sql)
clickhouse-client -d $DBNAME --queries-file <(curl -s https://raw.githubusercontent.com/PRX/castlehouse/main/schema/mv_backfill.sql)
clickhouse-client -d $DBNAME --queries-file <(curl -s https://raw.githubusercontent.com/PRX/castlehouse/main/schema/mv_increments.sql)
fi
# Augury
export DBNAME=${AuguryDatabase}
if test -z "$(clickhouse-client -d $DBNAME -q 'show tables')"; then
clickhouse-client -q "CREATE DATABASE $DBNAME"
fi
04_setup_users:
command: !Sub |
#!/bin/bash
# Rollups
clickhouse-client -q "CREATE USER OR REPLACE ${RollupsUsername} IDENTIFIED BY '${RollupsPassword}' SETTINGS PROFILE 'readonly'"
clickhouse-client -q "GRANT SHOW TABLES, SELECT ON ${RollupsDatabase}.* TO ${RollupsUsername}"
# Augury
clickhouse-client -q "CREATE USER OR REPLACE ${AuguryUsername} IDENTIFIED BY '${AuguryPassword}'"
clickhouse-client -q "GRANT ALL ON ${AuguryDatabase}.* TO ${AuguryUsername}"
files:
/etc/cfn/cfn-hup.conf:
# Create a configuration file for cfn-hup
Expand Down

0 comments on commit 2b21e52

Please sign in to comment.