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

Can't access custom CDK resource outputs from Lambda function #9630

Closed
4 tasks done
nathanagez opened this issue Jan 27, 2022 · 1 comment
Closed
4 tasks done

Can't access custom CDK resource outputs from Lambda function #9630

nathanagez opened this issue Jan 27, 2022 · 1 comment
Labels
duplicate If marked with duplicate, issue will be closed & original will be added for traceability extensibility Issues related to expand or customize current configuration feature-request Request a new feature

Comments

@nathanagez
Copy link

nathanagez commented Jan 27, 2022

Before opening, please confirm:

  • I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

How did you install the Amplify CLI?

yarn

If applicable, what version of Node.js are you using?

v14.17.0

Amplify CLI Version

7.6.13

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made

Amplify Categories

custom, function

Amplify Commands

push

Describe the bug

We don't have the ability to access output variables from custom CDK code in Lambda function.

Screenshot 2022-01-27 at 23 25 46

Expected behavior

We should be able to access output variables from custom resources using the dependsOn statement in the backend-config.json file.

Reproduction steps

Add custom resource:
amplify add custom select CDK and name it "video"

Add an CfnOutput value for this stack:

new cdk.CfnOutput(this, "outputKey", {
  value: "TEST_FROM_CDK"
});

Add Lambda function:
amplify add function

Update backend-config.json depnedsOn entry:

"yourLambda": {
      "build": true,
      "providerPlugin": "awscloudformation",
      "service": "Lambda",
      "dependsOn": [
        {
          "category": "custom",
          "resourceName": "video",
          "attributes": [
            "outputKey"
          ]
        }
      ]
    }

Update the Lambda CloudFormation stack:

  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"Amplify\",\"createdWith\":\"7.6.3\",\"stackType\":\"function-Lambda\",\"metadata\":{}}",
  "Parameters": {
    "CloudWatchRule": {
      "Type": "String",
      "Default": "NONE",
      "Description": " Schedule Expression"
    },
    "deploymentBucketName": {
      "Type": "String"
    },
    "env": {
      "Type": "String"
    },
    "s3Key": {
      "Type": "String"
    },
    "customvideooutputKey": {
      "Type": "String"
    }
  }

Populate parameter values:
amplify env checkout <your-env>

Deploy:
amplify push

Screenshot 2022-01-27 at 23 25 46

Note:

If someone can give me explanations on how the outputs are shared between the stacks and hints on how to implement this feature I might be able to do it!

GraphQL schema(s)

No response

Log output

No response

Additional information

No response

@johnpc johnpc added extensibility Issues related to expand or customize current configuration pending-triage Issue is pending triage labels Jan 31, 2022
@josefaidt
Copy link
Contributor

Hey @nathanagez 👋 thanks for raising this! Unfortunately this is not currently supported, however I've updated the title and labels on #9087 to better reflect the request. I'll mark this as a duplicate feature request, and for further updates please subscribe to #9087 🙂

@josefaidt josefaidt added duplicate If marked with duplicate, issue will be closed & original will be added for traceability feature-request Request a new feature and removed pending-triage Issue is pending triage labels Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate If marked with duplicate, issue will be closed & original will be added for traceability extensibility Issues related to expand or customize current configuration feature-request Request a new feature
Projects
None yet
Development

No branches or pull requests

3 participants