Skip to content

Commit

Permalink
cloud-init the keys
Browse files Browse the repository at this point in the history
  • Loading branch information
mojotalantikite committed Aug 14, 2023
1 parent c475d0a commit b6d40cc
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions services/postgres/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ resources:
- !Equals ['${sls:stage}', 'mtdbvm']
Mappings:
Logins:
mojo:
sshPublicKey: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDaR+UVq61k14jcuSFfoCfTxvB1IyhU3IQFp4OjpiN4fYMBjE9USeNoHon2ux8VTvL0nRc7Zn4g9HemxiDjdawUxh2oJ8GOTsiFTEWic2nf90SnbjBMn1OZELvMiZzoYDjQFvEp+AgETBA5nhrbHyxWQWIBa7A+XqiqnX0lcZ1p+x8sLIl4F0e583lJeuPQPVkpCicf2GDdtG1TnPxltqJgGaeVSONivpxeVofJwG4DCXy1b1xSo1NG0gzy9BWFJwOWKmZAk6nYq+rcxZg+TgU1x5WJ6z8/CS0PMSoTMRRIejm734PSmkGCU+WkR139Dl8o3DvQh/VQD71fxw30aONG98PSBJEUd5IouuiPPNYGP+fuDWgCBkaoA6JKlSVtbneNt1Qkm10FFHqExqzGWaSDeUCh6da3WG1BW4KZcC3MQ8CTEG47LFqUG5TvhklhiAAJH7cGF9W9SU1Beq2A6Wx1R/yGvgH/7U6X0/QfJi1ljY32pPzP2S+gzzOVGJgrMz3qRRgNvcY5k8EMbIuTK2yanFFHuVaWQq/zZW1T376oyHMfWdBB9WAtIKwpCgA5kYUu0XCo3XM0fWibZFIa/cEBNSKH1gEFKCBXolsc2+c4iZtdbG4YCHLgzOOqklERMEeK5dXq9Rz7UjoE91UVIyO2/d+mXmiVDRgtUsiQ34Sxyw== mojo.talantikite@gmail.com'
keys:
sshPublicKeys: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDaR+UVq61k14jcuSFfoCfTxvB1IyhU3IQFp4OjpiN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q8620UE7pA/FymFsZBxoYFNt0yJJPZcdHgRgYqs7m3fdEOHz9bgRHQBPP9cORtsx/JcJk7QCBvYRFatQiQm5Whe0p5tJfowwyl4NNEqaRnQhCupXipxnDlh8esxHNUlrioLzTUSs= mojo@test'

Resources:
# VPC endpoint for rotation lambda
Expand Down Expand Up @@ -177,7 +178,7 @@ resources:
config:
files:
'/home/ubuntu/.ssh/authorized_keys':
content: !FindInMap [Logins, 'mojo', 'sshPublicKey']
content: !FindInMap [Logins, 'keys', 'sshPublicKeys']
mode: '000600'
owner: 'ubuntu'
group: 'ubuntu'
Expand All @@ -196,7 +197,8 @@ resources:
UserData:
Fn::Base64: !Sub |
#!/bin/bash
apt update && apt install unzip postgresql postgresql-contrib -y
apt update && apt install unzip postgresql postgresql-contrib build-essential python3-pip -y
pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && unzip awscliv2.zip
./aws/install

Expand Down Expand Up @@ -240,6 +242,11 @@ resources:
systemctl start notify-slack
systemctl enable notify-slack

/usr/local/bin/cfn-init -v \
--stack ${AWS::StackName} \
--resource PostgresVM \
--region ${AWS::Region}

PgVMIAMRole:
Type: AWS::IAM::Role
Properties:
Expand Down

0 comments on commit b6d40cc

Please sign in to comment.