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

feat(cloudquery): Verify RDS SSL certificate #161

Merged
merged 1 commit into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion config/cloudquery/postgresql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ spec:

spec:
#TODO put credentials and adress later
connection_string: 'postgresql://postgres:£PASSWORD@£HOST:5432/postgres?sslmode=disable'
# See https://www.postgresql.org/docs/11/libpq-connect.html#LIBPQ-CONNECT-SSLMODE for sslmode options
connection_string: 'postgresql://postgres:£PASSWORD@£HOST:5432/postgres?sslmode=verify-full'
2 changes: 2 additions & 0 deletions packages/cdk/lib/__snapshots__/cloudquery.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,8 @@ PASSWORD=$(aws secretsmanager get-secret-value --secret-id ",
},
" | jq -r '.SecretString|fromjson|.password|@uri')
sed -i "s/£PASSWORD/$PASSWORD/g" postgresql.yaml
curl https://s3.amazonaws.com/rds-downloads/rds-ca-2019-root.pem -o /usr/local/share/ca-certificates/rds-ca-2019-root.crt
update-ca-certificates
systemctl enable cloudquery.timer
systemctl start cloudquery.timer",
],
Expand Down
4 changes: 4 additions & 0 deletions packages/cdk/lib/cloudquery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ export class CloudQuery extends GuStack {
`PASSWORD=$(aws secretsmanager get-secret-value --secret-id ${dbSecret} --region ${this.region} | jq -r '.SecretString|fromjson|.password|@uri')`,
`sed -i "s/£PASSWORD/$PASSWORD/g" postgresql.yaml`,

// Install RDS certificate
'curl https://s3.amazonaws.com/rds-downloads/rds-ca-2019-root.pem -o /usr/local/share/ca-certificates/rds-ca-2019-root.crt',
'update-ca-certificates',
Comment on lines +151 to +153
Copy link
Member Author

@akash1810 akash1810 Apr 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followed instructions from https://superuser.com/a/719047 to add the CA to the OS.

Copy link
Member Author

@akash1810 akash1810 Apr 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rds-ca-2019 certificate authority expires in 2024, and does not support automatic rotation, meaning we'll have to perform the rotation manually (with potential downtime).

We should move to the rds-ca-rsa2048-g1 CA, which does support automatic rotation.

See:

Copy link
Contributor

@NovemberTang NovemberTang Apr 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have a ticket planned to do this migration?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have a ticket planned to do this migration?

Not (yet) on trello, but we do have guardian/cdk#1786.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created the Trello card now - https://trello.com/c/gqPcnFh7.


'systemctl enable cloudquery.timer',
'systemctl start cloudquery.timer',
);
Expand Down