aws-amplify / aws-amplify/amplify-cli

How to control resources conditional on which environment Amplify is deploying to

Open
#13,860 3 comments 0 reactions 0 assignees View on GitHub
feature-request platform-config
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### 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

Contributor guide

Open the contributing guide

Research direction

The issue describes an Amplify Gen 1 project using separate AWS accounts for dev, sandbox, and prod, with a Cognito pre-authentication Lambda trigger needed only in prod. No source file, test, or entry point is named; begin by tracing how Amplify represents Cognito triggers and environment-specific configuration, then verify that the configuration survives CI deployment.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
authentication, cli, cloud
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.