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

Fn.GetAtt Expected Scalar got Intrinsic #4870

joekiller opened this issue Nov 5, 2019 · 3 comments

Fn.GetAtt Expected Scalar got Intrinsic #4870

joekiller opened this issue Nov 5, 2019 · 3 comments
bug language/python needs-triage


Copy link

@joekiller joekiller commented Nov 5, 2019

This might be another example of #2005. When I am trying to use values from CfnInclude resources I get jsii.errors.JSIIError: Expected Scalar, got {"$jsii.byref":"@aws-cdk/core.Intrinsic@10003"}

Reproduction Steps

from aws_cdk import (

app = core.App()
stack = core.Stack(app, "stack")
core.CfnInclude(stack, "RawStack", template={
    "Resources": {
        "MySnsTopic": {
            "Type": "AWS::SNS:Topic"
core.CfnOutput(stack, "TopicName", value=core.Fn.get_att('MySnsTopic', 'TopicName'))

Error Log

  Error: Expected Scalar, got {"$jsii.byref":"@aws-cdk/core.Intrinsic@10003"}
      at Object.deserialize (/tmp/test/venv/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:12601:23)
      at Kernel._toSandbox (/tmp/test/venv/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7353:61)
      at /tmp/test/venv/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:12777:29
      at mapValues (/tmp/test/venv/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:13006:27)
      at Object.deserialize (/tmp/test/venv/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:12773:20)
      at Kernel._toSandbox (/tmp/test/venv/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7353:61)
      at /tmp/test/venv/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7406:33
      at (<anonymous>)
      at Kernel._boxUnboxParameters (/tmp/test/venv/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7406:19)
      at Kernel._wrapSandboxCode (/tmp/test/venv/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7447:19)
      at Kernel._create (/tmp/test/venv/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:6992:26)
      at Kernel.create (/tmp/test/venv/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:6746:21)
      at KernelHost.processRequest (/tmp/test/venv/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:6521:28)
      at (/tmp/test/venv/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:6464:14)
      at Immediate._onImmediate (/tmp/test/venv/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:6467:37)
      at processImmediate (internal/timers.js:439:21)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "", line 15, in <module>
    core.CfnOutput(stack, "TopicName", value=core.Fn.get_att('MySnsTopic', 'TopicName'))
  File "/tmp/test/venv/lib/python3.7/site-packages/jsii/", line 66, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/tmp/test/venv/lib/python3.7/site-packages/aws_cdk/core/", line 3189, in __init__
    jsii.create(CfnOutput, self, [scope, id, props])
  File "/tmp/test/venv/lib/python3.7/site-packages/jsii/_kernel/", line 214, in create
  File "/tmp/test/venv/lib/python3.7/site-packages/jsii/_kernel/providers/", line 331, in create
    return self._process.send(request, CreateResponse)
  File "/tmp/test/venv/lib/python3.7/site-packages/jsii/_kernel/providers/", line 316, in send
    raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: Expected Scalar, got {"$jsii.byref":"@aws-cdk/core.Intrinsic@10003"}


  • CLI Version : 1.15.0 (build bdbe3aa)
  • Framework Version: 1.15.0
  • OS : Arch Linux
  • Language : Python 3.7


This really holds up being able to integrate or build upon old stacks.

This is 🐛 Bug Report

@joekiller joekiller added bug needs-triage labels Nov 5, 2019
@SomayaB SomayaB added the language/python label Nov 5, 2019
Copy link

@RomainMuller RomainMuller commented Nov 8, 2019

The value of CfnOutput must be a str, and you're passing some instance of an intrinsic function. You have to expressedly stringify that.

Copy link

@joekiller joekiller commented Nov 8, 2019

thanks @RomainMuller. Updating the get_att call in core.CfnOutput as follows fixed it up.


core.Fn.get_att('MySnsTopic', 'TopicName')


core.Fn.get_att('MySnsTopic', 'TopicName').to_string()

Copy link

@joekiller joekiller commented Nov 8, 2019

In retrospec @RomainMuller is would be nice if get_att implemented pthon's __str__ method because I did try str(core.Fn.get_att('MySnsTopic', 'TopicName')) and f'{core.Fn.get_att('MySnsTopic', 'TopicName')}' which returned the __repr__ of the object instead of the string. ( <aws_cdk.core.Intrinsic object at 0x7f0126872a50>)

I'll open another issue for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
bug language/python needs-triage
None yet

No branches or pull requests

3 participants