

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: Identity and Access Management (IAM)
incomplete
2: IAM Users
incomplete
3: Inline Policies
incomplete
4: IAM Groups
incomplete
5: IAM Roles
incomplete
6: Deny Policies
incomplete
7: SSM Parameters
incomplete
8: SSM Parameters Are Strings
incomplete
9: Accessing SSM Parameters from EC2
incomplete
10: Use SSM from EC2
incomplete
11: Cleanup
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
At this point, everything should be in place for our Pinger server to pull its config values from SSM:
/DATABASE_URL and /CMO_NAME in the SSM Parameter Store.patientping-ssm-access, allowing those params to be read.patientping-ec2-readonly-role.And the Pinger app code is already configured to try to pull config from SSM before falling back to a .env file. So once we restart the app, it should "just work."
The key idea here is that we can give one AWS resource (an EC2 instance) access to another resource (SSM params) by allowing it to assume an IAM role that has a relevant policy attached.
It may seem like a lot of ceremony, but this system allows fine-grained, auditable control over who gets access to what in an AWS account. IAM roles and permissions can be updated or revoked at any time, with changes taking effect almost immediately.
Restart the Pinger server on your EC2 instance, and confirm that the DATABASE_URL and CMO_NAME values are now coming from SSM.
If you're having connection issues, double-check that you stored the full connection string in SSM (including the postgresql:// prefix, username, password, and database name) - not just the RDS endpoint hostname. The DATABASE_URL value should look like: postgresql://postgres:PASSWORD@hostname:5432/patientping
cd ~/patientping-web
uv run patientping.py
Loaded DATABASE_URL and CMO_NAME from SSM (us-east-1)
PatientPing Chief Medical Officer: Dr. Strangelove
Run and submit the CLI tests.
If you want to verify the SSM params and the IAM role and policy via CLI, here are some commands to get you started:
# From your computer, logged into the AWS CLI as an admin user on your account,
# you can view SSM params directly
aws ssm get-parameter --name /DATABASE_URL
aws ssm get-parameter --name /CMO_NAME
# List inline policies attached to a role, e.g., "patientping-ssm-access"
aws iam list-role-policies --role-name patientping-ec2-readonly-role
# Show the details of an inline policy, given role and policy names
# Effect: "Allow"; Actions: "ssm:GetParameter" and "ssm:GetParameters"
# Resources: /DATABASE_URL and /CMO_NAME
aws iam get-role-policy --role-name patientping-ec2-readonly-role --policy-name patientping-ssm-access
# From an SSH session on your EC2 instance, run this to see its role
# The "Arn" value should have "assumed-role/patientping-ec2-readonly-role"
aws sts get-caller-identity