Exposed Amplify app OAuth token

Putting an Amplify app OAuth token in a template leaves repository credentials in code and history.

Description

Use OauthToken for a repository provider other than GitHub. Supply a token issued by that provider. For a new GitHub connection, use AccessToken.

Potential impact

A token in the template or a parameter default can remain in source history and grant whoever obtains it repository access within its permissions.

Remediation

Store the token in Secrets Manager and pass a dynamic reference. Revoke an exposed token at the provider and use a newly issued one if the connection needs reauthorization.

Examples

Set RepositoryUrl to the provider’s repository URL. MyAmpAppSecretManagerRotater takes the name or ARN of a secret containing the issued token under token.

Before

yaml
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
  RepositoryUrl:
    Type: String
Resources:
  NewAmpApp1:
    Type: AWS::Amplify::App
    Properties:
      Name: NewAmpApp
      Repository: !Ref RepositoryUrl
      OauthToken: EXAMPLE_NOT_A_REAL_OAUTH_TOKEN

After

yaml
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
  RepositoryUrl:
    Type: String
  MyAmpAppSecretManagerRotater:
    Type: String
Resources:
  NewAmpApp1:
    Type: AWS::Amplify::App
    Properties:
      Name: NewAmpApp
      Repository: !Ref RepositoryUrl
      OauthToken: !Sub '{{resolve:secretsmanager:${MyAmpAppSecretManagerRotater}:SecretString:token}}'

References