Configure Amplify Gen 2 backend with secrets
- Add secret definition to backend.ts using proper Amplify Gen 2 syntax - Update amplify.yml to include backend build phase - This should properly expose secrets as environment variables 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
21ac70c502
commit
b03225cf76
2 changed files with 17 additions and 7 deletions
13
amplify.yml
13
amplify.yml
|
@ -1,4 +1,10 @@
|
||||||
version: 1
|
version: 1
|
||||||
|
backend:
|
||||||
|
phases:
|
||||||
|
build:
|
||||||
|
commands:
|
||||||
|
- npm ci --cache .npm
|
||||||
|
- npx ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID
|
||||||
frontend:
|
frontend:
|
||||||
phases:
|
phases:
|
||||||
preBuild:
|
preBuild:
|
||||||
|
@ -7,11 +13,8 @@ frontend:
|
||||||
build:
|
build:
|
||||||
commands:
|
commands:
|
||||||
- echo "Build started on `date`"
|
- echo "Build started on `date`"
|
||||||
- echo "Configuring environment variables..."
|
- echo "Available environment variables:"
|
||||||
- echo "YOUTUBE_API_KEY value is ${YOUTUBE_API_KEY}"
|
- printenv | grep -E "(YOUTUBE|AMPLIFY)" || echo "No relevant env vars found"
|
||||||
- echo "YOUTUBE_API_KEY=${YOUTUBE_API_KEY}" > .env.production
|
|
||||||
- echo "Contents of .env.production file"
|
|
||||||
- cat .env.production
|
|
||||||
- npm run build
|
- npm run build
|
||||||
artifacts:
|
artifacts:
|
||||||
baseDirectory: .next
|
baseDirectory: .next
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
import { defineBackend } from '@aws-amplify/backend';
|
import { defineBackend, secret } from '@aws-amplify/backend';
|
||||||
import { auth } from './auth/resource';
|
import { auth } from './auth/resource';
|
||||||
import { data } from './data/resource';
|
import { data } from './data/resource';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see https://docs.amplify.aws/react/build-a-backend/ to add storage, functions, and more
|
* @see https://docs.amplify.aws/react/build-a-backend/ to add storage, functions, and more
|
||||||
*/
|
*/
|
||||||
defineBackend({
|
const backend = defineBackend({
|
||||||
auth,
|
auth,
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Define secrets that will be available as environment variables
|
||||||
|
backend.addOutput({
|
||||||
|
custom: {
|
||||||
|
YOUTUBE_API_KEY: secret('YOUTUBE_API_KEY'),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue