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

Having issues exporting AWS SSM parameter value to Nuxt environment variable #27211

Closed
nicholas5538 opened this issue May 14, 2024 · 0 comments
Closed

Comments

@nicholas5538
Copy link

Environment

Production

Reproduction

No reproduction is required.

Describe the bug

Deployment to production is successful, but I'm having some issues passing a parameter value from AWS SSM to a env file, it's undefined no matter what I do. Thus, my useAsyncData is returning an error.

Here are my codes for the amplify.yml file as well as the runtimeConfig object on my nuxt.config.ts file. Only config.githubSecret is undefined, the public githubBaseUrl is working.

Is AWS SSM not supported for deploying to production? Must I set the environment variables under the build settings on the AWS Amplify console?

Thanks in advance.

amplify.yml

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - nvm install 21.5.0 && node --version
        - corepack enable pnpm
        - pnpm install --frozen-lockfile
    build:
      commands:
        - export NUXT_GITHUB_SECRET=$(aws ssm get-parameter --name "/amplify/d2zk1p9qtbvjcd/main/AMPLIFY_secrets_nuxt_GITHUB_SECRET" --with-decryption --query Parameter.Value --output text)
        - echo "NUXT_GITHUB_SECRET=$NUXT_GITHUB_SECRET" >> .env
        - pnpm run build
  artifacts:
    baseDirectory: .amplify-hosting
    files:
      - "**/*"
  cache:
    paths:
      - node_modules/**/*

nuxt.config.ts

nitro: { preset: "aws-amplify" },
runtimeConfig: {
    /// Tried with githubSecret: "", not working as well
    githubSecret: process.env.NUXT_GITHUB_SECRET,
    public: {
      githubBaseUrl: "https://api.github.com",
    },
  },

Additional context

No response

Logs

# Starting phase: build

196

2024-05-14T14:30:43.692Z [INFO]: # Executing command: export NUXT_GITHUB_SECRET=$(aws ssm get-parameter --name "/amplify/d2zk1p9qtbvjcd/main/AMPLIFY_secrets_nuxt_GITHUB_SECRET" --with-decryption --query Parameter.Value --output text)

197

2024-05-14T14:31:00.963Z [INFO]: # Executing command: echo "NUXT_GITHUB_SECRET=$NUXT_GITHUB_SECRET" >> .env

198

2024-05-14T14:31:00.969Z [INFO]: # Executing command: pnpm run build

199

2024-05-14T14:31:01.368Z [INFO]: > portfolio-vue@ build /codebuild/output/src707491585/src/portfolio-vue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant