Learning Objectives
By the end of this chapter, you will be able to:
- Implement identity federation using SAML, OIDC, and Amazon Cognito while keeping data encrypted in transit and at rest and handling credentials securely inside application code.
- Issue and validate bearer tokens with JWT, OAuth 2.0, and AWS STS, and pair them with certificates issued by AWS Private CA for mutual TLS scenarios.
- Choose between Cognito user pools and identity pools for a given application flow and protect signing material with KMS key rotation.
- Combine resource-based, service control, and principal policies to express an authorization model that integrates with KMS symmetric and asymmetric keys.
- Apply role-based access control patterns in IAM and Cognito groups, and decide between client-side and server-side encryption per data store.
- Build application authorization on bucket and object ACLs where the workload still requires them, while classifying PII and PHI correctly.
- Write least-privilege IAM policies and keep sensitive configuration out of environment variables when stronger protection is warranted.
- Wire service-to-service communication onto IAM roles and pull secrets from AWS Secrets Manager and AWS Systems Manager Parameter Store at runtime.
Executive Summary
- DVA-C02 testing on security is dominated by code-level decisions: which token to validate, which policy attaches where, which encryption mode the SDK call sets, and which secret store the application reads at runtime.
- Identity federation, Cognito pools, and STS form one continuous chain: federated identity provides a token, Cognito or STS converts the token into AWS credentials, and the application calls AWS APIs under a role.
- Resource-based, service control, and principal policies are evaluated together; the SDK call only succeeds when every applicable policy allows the action and no policy explicitly denies it.
- Encryption at rest is selected through the SDK call and key choice; encryption in transit is selected through TLS, ACM certificates, and AWS Private CA for internal hostnames; key rotation and key separation belong to KMS configuration.
- Application code should never hold long-lived AWS access keys. Use roles, instance profiles, Lambda execution roles, ECS task roles, or Cognito-vended credentials, and pull secrets from Secrets Manager or Parameter Store.
Assumptions
- Reader has working knowledge of HTTP, TLS, OAuth 2.0 grant types, and JSON Web Tokens at a developer level.
- All examples use AWS SDK for JavaScript v3 or boto3 syntax interchangeably; commands run against the latest stable AWS CLI v2.
- Region in examples is
us-east-1unless otherwise stated; account IDs in policy snippets are placeholder values like111122223333. - The application is deployed across managed services (Lambda, ECS on Fargate, App Runner, or EC2 with an instance profile). Self-hosted secret stores are out of scope.
- Terms defined in Chapter 1 (event source mapping, eventual consistency, reserved concurrency, etc.) are not redefined here.
