Skip to content

Commit

Permalink
Add DBItentifier and remove old DB
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Sep 16, 2021
1 parent 92ecdb5 commit 35fcdf7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 45 deletions.
2 changes: 1 addition & 1 deletion cloudformation/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ const stack = {
{ Name: 'MAPBOX_TOKEN', Value: cf.ref('MapboxToken') },
{ Name: 'MAILGUN_API_KEY', Value: cf.ref('MailGun') },
{ Name: 'OPENCOLLECTIVE_API_KEY', Value: cf.ref('OpenCollective') },
{ Name: 'POSTGRES', Value: cf.join(['postgresql://openaddresses:', cf.ref('DatabasePassword'), '@', cf.getAtt('DBInstance', 'Endpoint.Address'), ':5432/openaddresses']) },
{ Name: 'POSTGRES', Value: cf.join(['postgresql://openaddresses:', cf.ref('DatabasePassword'), '@', cf.getAtt('DBInstanceVPC', 'Endpoint.Address'), ':5432/openaddresses']) },
{ Name: 'SharedSecret', Value: cf.ref('SharedSecret') },
{ Name: 'GithubSecret', Value: cf.ref('GithubSecret') },
{ Name: 'Bucket', Value: cf.ref('Bucket') },
Expand Down
46 changes: 2 additions & 44 deletions cloudformation/lib/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const stack = {
Properties: {
Engine: 'postgres',
DBName: 'openaddresses',
DBInstanceIdentifier: cf.stackName,
KmsKeyId: cf.ref('OAKMS'),
EngineVersion: '13.3',
MasterUsername: 'openaddresses',
Expand Down Expand Up @@ -52,25 +53,6 @@ const stack = {
}]
}
},
DBInstance: {
Type: 'AWS::RDS::DBInstance',
Properties: {
Engine: 'postgres',
DBName: 'openaddresses',
EngineVersion: '13.3',
MasterUsername: 'openaddresses',
MasterUserPassword: cf.ref('DatabasePassword'),
AllowMajorVersionUpgrade: true,
AllocatedStorage: 10,
MaxAllocatedStorage: 100,
BackupRetentionPeriod: 10,
StorageType: 'gp2',
DBInstanceClass: cf.ref('DatabaseType'),
DBSecurityGroups: [cf.ref('DBSecurityGroup')],
DBSubnetGroupName: cf.ref('DBSubnet'),
PubliclyAccessible: true
}
},
DBSubnet: {
Type: 'AWS::RDS::DBSubnetGroup',
Properties: {
Expand All @@ -85,40 +67,16 @@ const stack = {
]
}
},
DBSecurityGroup: {
Type: 'AWS::RDS::DBSecurityGroup',
Properties: {
GroupDescription: cf.join('-', [cf.stackName, 'rds-sg']),
EC2VpcId: 'vpc-3f2aa15a',
DBSecurityGroupIngress: [{
EC2SecurityGroupId: cf.getAtt('APIServiceSecurityGroup', 'GroupId')
},{
CIDRIP: '0.0.0.0/0'
}]
}
}

},
Outputs: {
DBVPC: {
Description: 'Postgres Connection String',
Value: cf.join([
'postgresql://openaddresses',
':',
cf.ref('DatabasePassword'),
'@',
cf.getAtt('DBInstanceVPC', 'Endpoint.Address'),
':5432/openaddresses'
])
},
DB: {
Description: 'Postgres Connection String',
Value: cf.join([
'postgresql://openaddresses',
':',
cf.ref('DatabasePassword'),
'@',
cf.getAtt('DBInstance', 'Endpoint.Address'),
cf.getAtt('DBInstanceVPC', 'Endpoint.Address'),
':5432/openaddresses'
])
}
Expand Down

0 comments on commit 35fcdf7

Please sign in to comment.