Skip to content

Bug: AWS::Serverless::Api automatically sets "arn:aws:iam::*:user/*" as integration execution role #8276

Closed

Description

@madakaheri

Description:

When creating an AWS::Serverless::Api with the following SAM template, the API Gateway integration request execution role is automatically set to arn:aws:iam::*:user/*.

This causes API Gateway → Lambda invocations to fail with a 500 error until the execution role is manually cleared in the console.

RestApi:
  Type: AWS::Serverless::Api
  Properties:
    Name: !Sub "${AWS::StackName}"
    Description: Application API
    StageName: !Ref Env
    Auth:
      DefaultAuthorizer: AWS_IAM
      AddDefaultAuthorizerToCorsPreflight: false

RestApiFunction:
  Type: AWS::Serverless::Function
  Properties:
    Runtime: nodejs22.x
    CodeUri: functions/rest-api
    Handler: src/index.handler
    Events:
      ApiGatewayProxy:
        Type: Api
        Properties:
          RestApiId: !Ref RestApi
          Path: /{proxy+}
          Method: ANY

Steps to reproduce:

  1. Deploy the above template with sam deploy.
  2. Inspect the API Gateway method integration in the AWS console.
  3. Observe that the integration request execution role is set to "arn:aws:iam:::user/".
  4. Call the endpoint → results in HTTP 500.
  5. Manually clear the execution role in the console → the API works as expected.

Observed result:

  • integration request contains "arn:aws:iam:::user/" as the execution role.
  • API Gateway fails to invoke the Lambda function, returning 500 errors.

Expected result:

  • For Lambda proxy integration, the execution role should remain empty.
  • Setting DefaultAuthorizer: AWS_IAM should not populate any execution role on the integration.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS:MacOS
  2. SAM CLI, version 1.132.0
  3. AWS region: ap-northeast-1
{
  "version": "1.132.0",
  "system": {
    "python": "3.11.10",
    "os": "macOS-26.0-arm64-arm-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "Not available",
    "aws_cdk": "Not available",
    "terraform": "Not available"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

Activity

  1. added
    stage/needs-triageAutomatically applied to new issues and PRs, indicating they haven't been looked at.
    on Sep 18, 2025
  2. madakaheri commented on Sep 18, 2025

    @madakaheri
    Author

    Sorry. This was my mistake.
    It worked when I set ApiFunctionAuth.InvokeRole of AWS::Serverless::Function to an empty string.

    RestApiFunction:
      Type: AWS::Serverless::Function
      Properties:
        Runtime: nodejs22.x
        CodeUri: functions/rest-api
        Handler: src/index.handler
        Events:
          ApiGatewayProxy:
            Type: Api
            Properties:
              RestApiId: !Ref RestApi
              Path: /{proxy+}
              Method: ANY
              Auth:
                Authorizer: AWS_IAM
                InvokeRole: "" # <-- add
  3. github-actions commented on Sep 18, 2025

    @github-actions
    Contributor

    ⚠️COMMENT VISIBILITY WARNING⚠️

    Comments on closed issues are hard for our team to see.
    If you need more assistance, please either tag a team member or open a new issue that references this one.
    If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stage/needs-triageAutomatically applied to new issues and PRs, indicating they haven't been looked at.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions