Open mishabruml opened 4 months ago
Hey, this is currently not supported on Amplify CLI. But the workaround would be to utilize the ENV
environment variable that Amplify deploy on the function by default and separate the config.
export const handler = (event) => {
if (process.env.ENV) {
return event
}
// your prod env logic
}
Marking as feature request
Thanks for the reply, thats really helpful to know. I ended up at this conclusion and had already implemented pretty much exactly what you suggested. Seems like if this functionality doesn't already exist then its a huge, core-level change so I should not expect anything in the immediate future?
Is there no way to manually modify the underlying cloudformation in order to acheive this?
Amplify CLI Version
12.12.4
Question
Hi there,
I've got a multi-environment project built with Amplify 12.12.4, Gen 1. Each environment (dev, sandbox, prod) deploys into it's own AWS account.
The project is basically hosting an s3-and-cloudfront site with cognito auth. The project is hooked up to be using amplify hosting/CI just like in this guide https://docs.amplify.aws/gen1/react/deploy-and-host/deployment/deploy-static-site-github/#deploy-your-app-to-aws-amplify
We have a requirement for a cognito pre-authentication lambda trigger to run some custom check before sign-in, but we only need this in prod.
I have successfully configured the lambda, but on all 3 environments; I only need it on prod. I can't find an straightforward way of configuring this through code.
It seems like based on answers such as https://github.com/aws-amplify/amplify-cli/issues/4875 that the answer relies on running amplify commands with the
--restore
flag, but this obviously isn't a persistent, source-control-backed change that will survive through CI etc.How can this environment-specific behvaiour be represented through code?
TL;DR: How can I configure, through commitable code, for cognito auth to have a trigger lambda, but in one amplify environment only
Thanks