amplify-backend
amplify-backend copied to clipboard
add a stack reference on backend resources
Environment information
System:
OS: macOS 14.3.1
CPU: (10) arm64 Apple M1 Pro
Memory: 103.66 MB / 32.00 GB
Shell: /opt/homebrew/bin/fish
Binaries:
Node: 20.11.1 - ~/Library/Caches/fnm_multishells/47118_1712176426928/bin/node
Yarn: 1.22.19 - ~/Library/Caches/fnm_multishells/47118_1712176426928/bin/yarn
npm: 10.2.4 - ~/Library/Caches/fnm_multishells/47118_1712176426928/bin/npm
pnpm: 8.15.5 - ~/Library/Caches/fnm_multishells/47118_1712176426928/bin/pnpm
NPM Packages:
@aws-amplify/backend: 0.13.0-beta.15
@aws-amplify/backend-cli: 0.12.0-beta.17
aws-amplify: 6.0.27
aws-cdk: 2.135.0
aws-cdk-lib: 2.135.0
typescript: 5.4.3
AWS environment variables:
AWS_PROFILE = josef-gen2
AWS_STS_REGIONAL_ENDPOINTS = regional
AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables
Description
It can be cumbersome to import Stack
to get a stack reference on a backend resource created with a define*
function. This is typically reached for when I add a custom policy or some additional resource with CDK that requires a scope
.
To remove the need for importing Stack
and referencing the stack of resources, add a property/method to reference the stack
from
import { defineBackend } from "@aws-amplify/backend"
import { Stack } from "aws-cdk-lib/core"
import { auth } from "./auth/resource"
import { data } from "./data/resource"
const backend = defineBackend({
auth,
data,
})
// pick an arbitrary resource to resolve the stack
const authStack = Stack.of(backend.auth.resources.userPool)
to
import { defineBackend } from "@aws-amplify/backend"
import { auth } from "./auth/resource"
import { data } from "./data/resource"
const backend = defineBackend({
auth,
data,
})
const authStack = backend.auth.stack
Marking as feature request to support to referencing stack as a method or property.