Having issues exporting AWS SSM parameter value to Nuxt environment variable
nicholas5538 opened this issue · comments
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