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?

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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠