Skip to main content
All IAM resources are managed in the 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

Each Lambda function that requires a custom IAM role has its own file in this directory. This keeps per-function permissions isolated and easy to audit.

IAM user and group

User: WallenstamTenant

This is the IAM user used for programmatic access to AWS resources from local development and Terraform.

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* and ListTagsForResource for 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:
  • AmazonDynamoDBFullAccess
  • AmazonS3FullAccess
  • AmazonSNSFullAccess
  • CloudWatchLogsFullAccess
  • SecretsManagerReadWrite

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.
Inline policies attached to this role: The AmazonDynamoDBReadOnlyAccess managed policy is also attached to allow the iOS app to read invoice data directly from DynamoDB if needed.

Cognito identity pool

The WallenstamAppIdentityPool 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.