iam child module at aws-infra-terraform/iam/. The module is invoked from the root main.tf and receives table ARNs, secret ARNs, and configuration variables as inputs.
Module structure
IAM user and group
User: WallenstamTenant
Group: Wallenstam
WallenstamTenant is a member of the Wallenstam group, which has the following AWS-managed policies attached:
Two additional inline policies are attached directly to the user (the group already has the maximum of 10 managed policies):
- TerraformAutoScalingPermissions —
application-autoscaling:Describe*andListTagsForResourcefor managing DynamoDB autoscaling - APIGatewayFullAccessPolicy —
apigateway:*for managing API Gateway resources
Lambda execution roles
Wallenstam-Lambda-Role
The primary shared execution role used by most Lambda functions. Attached managed policies:AmazonDynamoDBFullAccessAmazonS3FullAccessAmazonSNSFullAccessCloudWatchLogsFullAccessSecretsManagerReadWrite
Per-function roles
Several Lambda functions have dedicated execution roles with narrowly scoped inline policies. These are defined in the per-function IAM files:
Each file follows the same pattern: an
aws_iam_role with a Lambda trust policy, an aws_iam_policy with the minimum required permissions (typically DynamoDB table access and Secrets Manager read), and an aws_iam_role_policy_attachment binding the two.
Role ARNs are exported via outputs.tf and passed into the lambdas module by the root main.tf:
App identity role
WallenstamAppIdentityRole
This role is assumed by unauthenticated identities via the Cognito identity pool (WallenstamAppIdentityPool). It is used by the iOS app to register its APNs device token with SNS for push notifications.
The
AmazonDynamoDBReadOnlyAccess managed policy is also attached to allow the iOS app to read invoice data directly from DynamoDB if needed.
Cognito identity pool
TheWallenstamAppIdentityPool Cognito identity pool is defined in cognito.tf. It provides unauthenticated guest access for the iOS app, enabling it to call sns:CreatePlatformEndpoint to register for push notifications without requiring a full Cognito user pool login.
The identity pool is linked to WallenstamAppIdentityRole as its unauthenticated role.