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

CDK v2 - Go: Cannot use Fn If in allowed by Cloudformation way #14342

Closed
xrn opened this issue Apr 23, 2021 · 4 comments
Closed

CDK v2 - Go: Cannot use Fn If in allowed by Cloudformation way #14342

xrn opened this issue Apr 23, 2021 · 4 comments
Assignees
Labels
@aws-cdk/core Related to core CDK functionality bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@xrn
Copy link

xrn commented Apr 23, 2021

I have code like

	lambdaFn := awslambda.NewFunction(stack, jsii.String("Singleton"), &awslambda.FunctionProps{
		Code:    awslambda.NewAssetCode(jsii.String("lambda"), nil),
		Handler: jsii.String("handler.main"),
		Timeout: awscdk.Duration_Seconds(jsii.Number(300)),
		Runtime: awslambda.Runtime_PYTHON_3_6(),
	})

	awscognito.NewUserPool(stack, aws.String("UserPoll"), &awscognito.UserPoolProps{
		UserPoolName: awscdk.Fn_Sub(aws.String("${Environment}-SC-Pool"), nil),
		LambdaTriggers: awscdk.Fn_ConditionIf("Condition",
			&awscognito.UserPoolTriggers{
				PostAuthentication: lambdaFn,
			},
			&awscognito.UserPoolTriggers{},
		),
	})

Which from perspective Cloudfroamtion should work - I can create if statement for the whole object. But Fn_ConditionIf returns type ICfnConditionExpression and I am expecting &awscognito.UserPoolTriggers

Reproduction Steps

Code attached

What did you expect to happen?

If statement should be allowed

What actually happened?

If statement could not be used here because of type

Environment

  • **aws-cdk@2.0.0-alpha.12
  • **OS: MP Debian 5.10.28-1 (2021-04-09) x86_64 GNU/Linux
  • Language (Version): Go 1.16.3
@xrn xrn added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 23, 2021
@github-actions github-actions bot added @aws-cdk/aws-cloudformation Related to AWS CloudFormation aws-cdk-lib Related to the aws-cdk-lib package labels Apr 23, 2021
@nija-at
Copy link
Contributor

nija-at commented May 5, 2021

Hi @xrn -

You will need to convert ICfnConditionExpression into an any token. Something like this -

LambdaTriggers: awscdk.Token_asAny(awscdk.Fn_ConditionIf("Condition",
  &awscognito.UserPoolTriggers{
    PostAuthentication: lambdaFn,
  },
  &awscognito.UserPoolTriggers{},
)),

Can you check if that works?

@nija-at nija-at added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label May 5, 2021
@nija-at nija-at added @aws-cdk/core Related to core CDK functionality and removed @aws-cdk/aws-cloudformation Related to AWS CloudFormation aws-cdk-lib Related to the aws-cdk-lib package labels May 5, 2021
@xrn
Copy link
Author

xrn commented May 5, 2021

Hi @nija-at, thanks for answer

LambdaTriggers: awscdk.Token_AsAny(awscdk.Fn_ConditionIf(aws.String("Condition"),
			&awscognito.UserPoolTriggers{
				PostAuthentication: lambdaFn,
			},
			&awscognito.UserPoolTriggers{},
		)),

Still do not work because Token_AsAny returns IResolvable and LambdaTriggers is expecting awscognito.UserPoolTriggers type

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label May 6, 2021
@nija-at
Copy link
Contributor

nija-at commented May 6, 2021

I believe this is a Go question targeted to the jsii repo.
I believe you already have an issue open there - aws/jsii#2798

Closing this as a dupe.

@nija-at nija-at closed this as completed May 6, 2021
@github-actions
Copy link

github-actions bot commented May 6, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/core Related to core CDK functionality bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

3 participants