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

(CustomResources): Error: Resolution error: Resolution error: Trying to resolve() a Construct at /Resources/${Token[ #30339

Open
AllanOricil opened this issue May 25, 2024 · 3 comments
Labels
@aws-cdk/custom-resources Related to AWS CDK Custom Resources bug This issue is a bug. effort/medium Medium work item – several days of effort p3

Comments

@AllanOricil
Copy link

AllanOricil commented May 25, 2024

Describe the bug

When attempting to synthesize a custom resource that creates resources in Salesforce, I get the following error

image

Expected Behavior

I was expecting to see SalesforceObject and SalesforceObjectFields as properties of "Custom::SalesforceMetadata" in the synthesized template

"salesforcemetadataSalesforceMetadataResourceFCFF42F2": {
   "Type": "Custom::SalesforceMetadata",
   "Properties": {
    "ServiceToken": {
     "Fn::GetAtt": [
      "salesforcemetadataSalesforceProviderframeworkonEventD0B8B143",
      "Arn"
     ]
    }

    // SalesforceObject
    // SalesforceObject.SalesforceObjectField

   },
   "UpdateReplacePolicy": "Delete",
   "DeletionPolicy": "Delete",
   "Metadata": {
    "aws:cdk:path": "cdk-salesforce-iac-poc-stack/salesforce-metadata/SalesforceMetadataResource/Default"
   }
  },

Current Behavior

cdk synth doesn't finish and throws the folllowing error

image

Reproduction Steps

Run cdk synth in this repo

https://github.com/AllanOricil/cdk-salesforce-iac-poc

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.141.0

Framework Version

No response

Node.js Version

18.19.1

OS

macos latest

Language

TypeScript

Language Version

5.4.5

Other information

My goal with this custom construct it to be able to use a single tool to develop solutions that require both Salesforce and AWS resources. This simplest repository I shared is attempting to create a very simple Database Table in Salesforce (they call it SObject, but let's try to use terms which both of us understand even if it is wrong). I want to join all salesforce resources under one called "SalesforceMetadata" so that it represents all metadata that belongs to a single Salesforce Organization. Moreover, I did not create custom resources for SalesforceObject and SalesforceObjectField constructs because I wan't them to be deployed by Custom::SalesforceMetadata. In other words, they can't be deployed alone.

I want to build something like Mongodb Atlas did

https://github.com/mongodb/awscdk-resources-mongodbatlas

@AllanOricil AllanOricil added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 25, 2024
@github-actions github-actions bot added the @aws-cdk/custom-resources Related to AWS CDK Custom Resources label May 25, 2024
@AllanOricil AllanOricil changed the title (CustomResource): Error: Resolution error: Resolution error: Trying to resolve() a Construct at /Resources/${Token[ (CustomResources): Error: Resolution error: Resolution error: Trying to resolve() a Construct at /Resources/${Token[ May 25, 2024
@AllanOricil
Copy link
Author

Anybody who can help here?

@pahud
Copy link
Contributor

pahud commented May 31, 2024

Your PoC is a little bit too much for us to help and as we don't have SaleForce credentials we can't help you debug like that.

Generally, you will need to simplify your code and first make sure you can successfully create the custom resource.

https://github.com/AllanOricil/cdk-salesforce-iac-poc/blob/274930054cecda7475b5c2cf84b21a1d3b0b24cd/lib/constructs/salesforce-metadata.ts#L51-L57

new cdk.CustomResource(this, "SalesforceMetadataResource", {
      serviceToken: salesforceProvider.serviceToken,
      resourceType: "Custom::SalesforceMetadata",
      properties: {
        objects: this.objects,
      },
    });

Are you able to create a simple custom resource like that first, iterate from there and see what makes it fail on synth?

@pahud pahud added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. p3 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels May 31, 2024
@AllanOricil
Copy link
Author

AllanOricil commented Jun 1, 2024

@pahud when removing the other construct called SalesforceObject from the stack, as well as its field, the synthesis happen with no problem.

What is wrong with the SalesforceObject construct? I could declare it as a simple class, but would cdk be able to tell me what has changed in the SalesforceMetada construct? Additionally, would the class props be in the synthesized template?

I don't want to make another custom provider for SalesforceObject, or SalesforceObjectField, because I think that If I do it, I will have to create a lambda function for it as well, and that it will be deployable by its own, and I don't want it because I want the SalesforceMetadata construct to be the only deployable resource.

When creating a SalesforceMetadata, I want its lambda function to have refs for all other constructs that composes it, so that the lambda can generate the Ifrastructure manifest that salesforce actually uses.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/custom-resources Related to AWS CDK Custom Resources bug This issue is a bug. effort/medium Medium work item – several days of effort p3
Projects
None yet
Development

No branches or pull requests

2 participants