Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variables from SSM Parameter Store or Secrets Manager #2512

Open
callumthomson opened this issue Jan 14, 2022 · 4 comments
Open
Labels
feature-request New feature or request

Comments

@callumthomson
Copy link

It seems currently the only way to set environment variables on an Amplify app is by providing a plaintext value. It would be really useful to provide them from Parameter Store or Secrets Manager. I have an app which requires private npm authentication during the build stage. Currently I have to provide the GitHub personal access token to Amplify as a plaintext value. I also have to remember to update it here when I regenerate the token.

@callumthomson callumthomson added the feature-request New feature or request label Jan 14, 2022
@github-actions
Copy link

Hi 👋, thanks for opening! While we look into this...

If this issue is related to custom domains, be sure to check the custom domains troubleshooting guide to see if that helps. Also, there is a more general troubleshooting FAQ that may be helpful for other questions.

Lastly, please make sure you've specified the App ID and Region in the issue!

@artgibson
Copy link

Is this in the pipeline?

@alexabidri
Copy link

alexabidri commented Jul 21, 2023

I was able to make it work by accessing directly the SSM store through the AWS CLI in the Amplify Build. As mentioned previously, I also needed to use npm private registry in my build to build my nextjs application.

Here is the Amplify config:

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - export GITHUB_API_TOKEN=$(aws ssm get-parameter --name GITHUB_API_TOKEN --query Parameter.Value --output text --with-decryption)
        - echo $GITHUB_API_TOKEN
        - npm config set //npm.pkg.github.com/:_authToken $GITHUB_API_TOKEN
        - npm ci
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: .next
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

Cheers 👌🏻

@jjuannn
Copy link

jjuannn commented Apr 8, 2024

Hey @alexabidri 👋🏻 Is there any previous setup that needs to be done in order of access to the AWS CLI commands? I tried with

export RECAPTCHA_SITE_KEY=$(aws ssm get-parameter --name RECAPTCHA_SITE_KEY --query Parameter.Value --output text --with-decryption)

but I get this error:

aws: command not found

Are you using a specific build image? I'm using public.ecr.aws/docker/library/node:18.17.0.

Edit: solved this issue by installing the AWS CLI manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants