question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't get a CfnInstance with instance.getInstance()

See original GitHub issue

🐛 Bug Report

What is the problem?

Can’t get a CfnInstance with instance.getInstance(). I was hoping to get a CfnInstance to see if I can pass it in to Targets of CfnMaintenanceWindowTargetProps.

Reproduction Steps

(let [app (new App)
      stack (new Stack app "stack" stack-props)
      vpc (new Vpc stack "vpc")
      instance (new Instance stack "server" instance-props)
      window (new CfnMaintenanceWindow stack "window" maintenance-window-props)
      target (new CfnMaintenanceWindowTarget stack "target" maintenance-window-target-props)]
  (.getInstance instance)
  (.synth app))

Verbose Log

Execution error (IllegalArgumentException) at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder/getSetter (POJOPropertyBuilder.java:497). Conflicting setter definitions for property “networkInterfaces”: software.amazon.awscdk.services.ec2.CfnInstance#setNetworkInterfaces(1 params) vs software.amazon.awscdk.services.ec2.CfnInstance#setNetworkInterfaces(1 params) class software.amazon.jsii.JsiiException

or

Execution error (IllegalArgumentException) at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder/getSetter (POJOPropertyBuilder.java:497). Conflicting setter definitions for property “blockDeviceMappings”: software.amazon.awscdk.services.ec2.CfnInstance#setBlockDeviceMappings(1 params) vs software.amazon.awscdk.services.ec2.CfnInstance#setBlockDeviceMappings(1 params)

Environment

  • CDK CLI Version: 1.8.0 (build 5244f97)
  • Module Version: 1.8.0.DEVPREVIEW
  • OS: MacOS Mojave
  • Language: Java

Other information

JsiiObjectMapper.java: 57 software.amazon.jsii.JsiiObjectMapper/treeToValue
JsiiObject.java: 111 software.amazon.jsii.JsiiObject/jsiiGet
Instance.java: 66 software.amazon.awscdk.services.ec2.Instance/getInstance
RestFn.java: 1523 clojure.lang.RestFn/invoke
AFn.java: 22 clojure.lang.AFn/run
AFn.java: 22 clojure.lang.AFn/run
Thread.java: 748 java.lang.Thread/run

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
rix0rrrcommented, Sep 25, 2019

The reason probably being that the Java code contains an overloaded setter that Jackson can’t pick between:

    /**
     * `AWS::EC2::Instance.BlockDeviceMappings`.
     * 
     * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html#cfn-ec2-instance-blockdevicemappings
     */
    @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.External)
    public void setBlockDeviceMappings(final software.amazon.awscdk.core.IResolvable value) {
        this.jsiiSet("blockDeviceMappings", value);
    }

    /**
     * `AWS::EC2::Instance.BlockDeviceMappings`.
     * 
     * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html#cfn-ec2-instance-blockdevicemappings
     */
    @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.External)
    public void setBlockDeviceMappings(final java.util.List<java.lang.Object> value) {
        this.jsiiSet("blockDeviceMappings", value);
    }
0reactions
RomainMullercommented, Nov 28, 2019

The fix for this will roll out in the next CDK release. I’ll resolve this issue for now, please re-open if you still encounter the problem once the new release (probably 1.19.0) is out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CfnInstance - AWS Documentation - Amazon.com
Specifies an EC2 instance. If an Elastic IP address is attached to your instance, AWS CloudFormation reattaches the Elastic IP address after it...
Read more >
How to get instance ID of created EC2 instance - Stack Overflow
Trying to get the instance ID of an EC2 instance created by CF (generated by ... 'instanceId' does not exist on type 'CfnInstance'.ts(2339)....
Read more >
CDK: How to create EC2.Instance (not CfnInstance) in VPC ...
I can't use Vpc.FromLookup because the VPC doesn't exist before the stack runs. I can't use Vpc.FromVpcAttributes because it can't have ...
Read more >
awsec2 - Go Packages
Construct, id *string, props *CfnInstanceProps) CfnInstance ... this to PUBLIC if you need to connect to this instance via the internet and cannot...
Read more >
CfnInstance (software.amazon.awscdk:ec2 1.48.0 API)
static interface, CfnInstance. ... CfnInstance(Construct scope, String id, CfnInstanceProps props) ... String · getInstanceInitiatedShutdownBehavior().
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found