Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to get stack region & account ID from backend resources #2284

Open
dreamorosi opened this issue Nov 29, 2024 · 1 comment
Open

Ability to get stack region & account ID from backend resources #2284

dreamorosi opened this issue Nov 29, 2024 · 1 comment
Assignees
Labels
feature-request New feature or request function Issue pertaining to Amplify Function

Comments

@dreamorosi
Copy link

dreamorosi commented Nov 29, 2024

Environment information

System:
  OS: macOS 15.1.1
  CPU: (12) arm64 Apple M2 Pro
  Memory: 137.39 MB / 32.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 20.12.2 - ~/.local/state/fnm_multishells/13709_1732902102431/bin/node
  Yarn: 1.22.22 - ~/.local/state/fnm_multishells/13709_1732902102431/bin/yarn
  npm: 10.5.0 - ~/.local/state/fnm_multishells/13709_1732902102431/bin/npm
  pnpm: 9.6.0 - ~/.local/state/fnm_multishells/13709_1732902102431/bin/pnpm
NPM Packages:
  @aws-amplify/auth-construct: 1.5.0
  @aws-amplify/backend: 1.8.0
  @aws-amplify/backend-auth: 1.4.1
  @aws-amplify/backend-cli: 1.4.2
  @aws-amplify/backend-data: 1.2.1
  @aws-amplify/backend-deployer: 1.1.10
  @aws-amplify/backend-function: 1.8.0
  @aws-amplify/backend-output-schemas: 1.4.0
  @aws-amplify/backend-output-storage: 1.1.3
  @aws-amplify/backend-secret: 1.1.5
  @aws-amplify/backend-storage: 1.2.3
  @aws-amplify/cli-core: 1.2.0
  @aws-amplify/client-config: 1.5.2
  @aws-amplify/deployed-backend-client: 1.4.2
  @aws-amplify/form-generator: 1.0.3
  @aws-amplify/model-generator: 1.0.9
  @aws-amplify/platform-core: 1.2.2
  @aws-amplify/plugin-types: 1.5.0
  @aws-amplify/sandbox: 1.2.6
  @aws-amplify/schema-generator: 1.2.5
  aws-amplify: 6.10.0
  aws-cdk: 2.171.1
  aws-cdk-lib: 2.171.1
  typescript: 5.7.2
CDK environment variables:
  CDK_DOCKER = finch

Describe the feature

When working with many CDK resources, it's useful to have access to the region and account ID of the stack where I'm deploying my Amplify app.

Hardcoding these values can be problematic at times, so ideally I'd like to be able to interpolate these values, similar to what I can do already in CDK.

Ideally, I'd like to be able to do something like this or similar to this:

import { defineFunction, stack } from "@aws-amplify/backend";

export const myFunction = defineFunction({
  name: "my-function",
  layers: {
   "@aws-lambda-powertools/*":
      `arn:aws:lambda:${stack.region}:${stack.account}:layer:myLayer:12`,
  },
});

alternatively, I'd like to be able to use a regular CloudFormation variable and have Amplify leave it as-is in the final stack:

import { defineFunction, stack } from "@aws-amplify/backend";

export const myFunction = defineFunction({
  name: "my-function",
  layers: {
   "@aws-lambda-powertools/*":
      "arn:aws:lambda:\${AWS::Region}:123456789012:layer:myLayer:12"
  },
});

Use case

For example, when working with Lambda layers, customers need to specify the ARN of the layer they want to attach to a function. These ARNs need to be in the same region where the function is being deployed.

Hardcoding the region makes the stack not portable.

@dreamorosi dreamorosi added the pending-triage Incoming issues that need categorization label Nov 29, 2024
@ykethan
Copy link
Member

ykethan commented Nov 29, 2024

Thank you for filing this, marking this as feature request for further improvements.

@ykethan ykethan added feature-request New feature or request function Issue pertaining to Amplify Function and removed pending-triage Incoming issues that need categorization labels Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request function Issue pertaining to Amplify Function
Projects
None yet
Development

No branches or pull requests

2 participants