How do create an Amplify app via CloudFormation without using AWS Console?

0

At my employer, we use CloudFormation for managing our stacks. In the case of Amplify, I want to add an Amplify resource to my template.yml and have AWS provision it.

The docs say that I need an access token (I'm using GitHub) in order to do this. The docs also say that the only way to get that access token is to create an Amplify app via the AWS console. I don't want to do this and even if I did, I am not an admin for our GitHub repositories so I can't.

How can this be done without touching the AWS console?

Sam
質問済み 7ヶ月前416ビュー
1回答
0

Hello Once you have the PAT, you should store it securely in AWS Secrets Manager.

Use AWS CLI to create a secret:

aws secretsmanager create-secret --name GitHubToken --description "GitHub Personal Access Token" --secret-string "YOUR_GITHUB_TOKEN"

Remember the ARN of the secret you just created, as it will be needed in the CloudFormation template.

Create CloudFormation Template Now you can create a CloudFormation template that provisions the Amplify app:

Resources:
  MyAmplifyApp:
    Type: "AWS::Amplify::App"
    Properties:
      Name: MyAppName
      Repository: https://github.com/yourusername/yourrepository.git
      AccessToken: !Sub
        - '{{resolve:secretsmanager:${SecretARN}:SecretString:token}}'
        - SecretARN: arn:aws:secretsmanager:region:account-id:secret:GitHubToken-abcdef
      OauthToken: !Sub
        - '{{resolve:secretsmanager:${SecretARN}:SecretString:token}}'
        - SecretARN: arn:aws:secretsmanager:region:account-id:secret:GitHubToken-abcdef

Deploy the CloudFormation Template Now you can deploy the CloudFormation template using the AWS CLI or any CI/CD pipeline you have in place:

aws cloudformation deploy --template-file template.yml --stack-name MyAmplifyStack

After the stack is successfully created, AWS will provision an Amplify app connected to your GitHub repository using the Personal Access Token stored in AWS Secrets Manager.

Regards, Andrii

profile picture
エキスパート
回答済み 7ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ