

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
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
Storing parameters in the SSM Parameter Store is only half the equation. Your EC2 instances still need permission to retrieve them, which they can get through IAM. To allow an instance to access SSM parameters, you need to:
ssm:GetParameter permissions.However, doing this for each individual parameter would get tedious, real quick. Instead, we can scope access with parameter names or path namespaces using a policy like this:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowReadSSMParameters",
"Effect": "Allow",
"Action": ["ssm:GetParameter", "ssm:GetParameters"],
"Resource": [
"arn:aws:ssm:*:*:parameter/DATABASE_URL",
"arn:aws:ssm:*:*:parameter/CMO_NAME"
]
}
]
}
This gives us a pretty flexible system. For example, you could organize parameters using namespaces like:
/global/ namespace for all servers in the environment/cloudsy/ namespace for all servers that are part of a cloudsy application/env/debug/ namespace for all servers in the debug environmentCost check: IAM roles and policies are free. Granting EC2 access to SSM parameters doesn't add cost; you only pay for the EC2 instances (and SSM "advanced parameters," if any).
Add an inline policy patientping-ssm-access to the role patientping-ec2-readonly-role. Allow ssm:GetParameter and ssm:GetParameters for /DATABASE_URL and /CMO_NAME.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["ssm:GetParameter", "ssm:GetParameters"],
"Resource": [
"arn:aws:ssm:*:*:parameter/DATABASE_URL",
"arn:aws:ssm:*:*:parameter/CMO_NAME"
]
}
]
}
Run and submit the CLI tests.
For CLI users, here's how to create and attach an inline policy:
aws iam put-role-policy --role-name ROLE-NAME --policy-name POLICY-NAME --policy-document file://POLICY-FILE.json