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
feita há 7 meses417 visualizações
1 Resposta
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
ESPECIALISTA
respondido há 7 meses

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas