SAA-C03 ยท Roles, federation and cross-account access
IAM roles and temporary credentials
Roles for AWS services (EC2 instance profiles, Lambda execution roles), AWS STS temporary credentials and why roles beat stored access keys.
Key points
- IAM role: identity with permissions but no password or long-term keys.
- Assumed by: EC2 instance (instance profile), Lambda function (execution role), a user or another account.
- AWS STS returns temporary credentials: access key ID, secret access key, session token, expiration time.
- They expire on their own, so nothing permanent is stored in code, AMIs or config files.
Source: https://docs.aws.amazon.com/cli/latest/reference/sts/assume-role.html
Practice questions
Besides an access key ID and a secret access key, what does a successful sts:AssumeRole call return?
- A console password and an MFA seed
- A session token and an expiration time
- An X.509 signing certificate and a key pair
- A refresh token valid for 30 days
Show answer
Answer: B. A session token and an expiration time
Temporary credentials always come with a session token and an expiration time; requests signed without the token are rejected. STS does not issue passwords, MFA seeds or X.509 certificates for role sessions.
Which statements about EC2 instance profiles are correct?
- An instance profile can contain only one IAM role
- Creating an EC2 role in the console also creates an instance profile with the same name
- Applications on the instance get temporary credentials that are refreshed automatically
- Credentials delivered through an instance profile never expire
- An instance profile can hold up to five roles after a quota increase
Show answer
Answer: A. An instance profile can contain only one IAM role, B. Creating an EC2 role in the console also creates an instance profile with the same name, C. Applications on the instance get temporary credentials that are refreshed automatically
An instance profile holds exactly one role (a hard limit), the console creates a same-named instance profile when you create a role for EC2, and the instance receives temporary credentials that are refreshed automatically. The credentials do expire, and the one-role limit cannot be raised.
To give an EC2 instance the permissions of two different roles, you can add both roles to its instance profile.
Show answer
Answer: False
False. An instance profile holds only one role and that limit cannot be increased. Combine the needed permissions in one role (or have the application assume a second role through STS).
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
