Closed ruggero-balteri closed 2 years ago
found the problem. In API-stack import the property Queue from SQS-stack and I use it inside the .replace()
function (not inside a cdk construct).
Cdk, which should be in charge or creating the "wiring" between stacks, ignores the properties that are not used inside stacks, including the IQueue. As a workaround, I just instantiated the following resource (which I am not using) to setup the wiring.
new cdk.CfnOutput(this, "WorkaroundForWiring", {
value: SqsSqs.queueName,
});
Since CfnOutput
is a construct, the queueName is now exported from SQS stack and imported in API stack and can be use.
Why is this workaround necessary? Shouldn't cdk take care of this situations without the need of a component?
@ruggero-balteri you're right it should. This is likely a bug in appsync.
@MrArnoldPalmer not quite sure why it would be an appsync bug tho? I'm also not that much of an expert on cross-stack implementation under the hood.
But what I'm guessing is happening is that CDK creates a token that resolves later, and in the case of this bug report, the token isn't being created and thus not resolved properly?
I'm not sure if it is, but I was thinking there is a possibility we are doing something wrong referencing the IQueue
that prevents it from being properly exported from the stack that makes it, which is required to reference it in the api stack.
Just ran into this myself, in this case referencing a Lambda ARN from one stack in a custom resource (wraps CfnCustomResource) in another stack.
Luckily, that other stack only had a single construct in it, so I simply replicated the construct into the same stack that creates the Lambda.
Obviously this a corner case. The workaround posted above might be a solution in this case, but I haven't tried it.
@adworacz are you comfortable sharing how you were referencing the Lambda ARN? More examples will definitely help resolve this case!
Yup it was something like the following:
class LambdaStack extends DeploymentStack {
public readonly lambdaArn: string
constructor(...) {
const lambdaFunction = new Function(this, ...)
this.lambdaArn = lambdaFunction.functionArn
...
}
}
class CustomResourceStack extends DeploymentStack {...}
const lambdaStack = new LambdaStack(...)
const customResourceProps = {
uri: `arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/${lambdaStack.lambdaArn}/invocations`
}
const customResourceStack = new CustomResourceStack(..., customResourceProps)
Okay I think this is an issue
with the core library. And what seems to be the issue is whenever there is string interpolation using a token, CDK treats the token as undefined?
@MrArnoldPalmer I'm pretty sure this is the error, but would like your thoughts
This could definitely be a problem with tokens and string interpolation though that is supposed to work in general. It would require more investigation on our end I think to rule out a problem with the AppSync constructs still.
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.
Hey folks I just hit the same issue here. In our organization we are not allowed to generate our own KMS keys rather request via Service catalog. I used the L1 construct that is in a BaseStack to generated the SC product which outputs the Kms ARN. In that stack I create the Ikey
using the fromArn
method. Just deploying that stack alone works as expected.
In my second stack I try to pass the public readonly Ikey
from the base stack and hit the error:
Template error: instance of Fn::GetAtt references undefined resource DeltaKmsProvisionedProduct
I got around this by just using CFNOutputs
. Would be nice if we could just reference the public Ikey
from the class
Hi all, I also hit the same (or at least very similar) issue. I'm getting the error: Template error: instance of Fn::GetAtt
references undefined resource EmrSecurityGroupFGACF683B51A on deploy. No error on stack build. I have basically the following situation:
# stack A
...
this.fgacSecurityGroup = new SecurityGroup(...)
...
# app.ts
const stackA = new StackA(...)
new StackB(... {
fgacSecurityGroup: stackA.fgacSecurityGroup
...
}
# stack B
...
const jsonBlob = {
securityGroupToUseInEMR: fgacSecurityGroup
}
Was there any resolution for this existing issue?
I have 2 stacks:
I want to simply pass the SQS queue (defined in the SQS stack) to the API stack
The code synthesizes correctly, but it fails at deployment with error:
Reproduction Steps
cdk.ts
API-stack
SQS stack
What did you expect to happen?
CDK should have handled the routing and make sure that the appropriate resources (e.g. StudentQueue68D52AA1) was exported correctly
What actually happened?
The appropriate resource was not exported from SQS-stack
Environment
Other
This issue might be similar https://github.com/aws/aws-cdk/issues/3619
Synth SQS stack
Synth API stack
This is :bug: Bug Report