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

EC2 StartInstance "SyntaxError: Unexpected token i in JSON at position 0" #81

Open
JohnnyPicnic opened this issue Nov 29, 2021 · 5 comments

Comments

@JohnnyPicnic
Copy link

When I put an instance Id in the EC2 node I get:
"SyntaxError: Unexpected token i in JSON at position 0"

When passing msg.InstanceIds.1=isntanceid I get:
"failed: InvalidParameterType: Expected params.InstanceIds to be an Array"

@Daniel-t
Copy link
Owner

Also it’s asking for an array, but it doesn’t look like you’re passing one. Try msg.InstanceIds=[isntanceid]

@JohnnyPicnic
Copy link
Author

JohnnyPicnic commented Nov 29, 2021

I'm using an inject node to pass the parameters. EC2 StartInstance.
tried setting msg.InstanceIds=[isntanceid] and got "SyntaxError: Unexpected token i in JSON at position 1"

[{"id":"a7e04ee08e02e01f","type":"inject","z":"54477b72.9b0d74","name":"","props":[{"p":"InstanceIds","v":"[i-aaaaaaa]","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":240,"y":310,"wires":[["4a44c52eb032248e"]]},{"id":"4a44c52eb032248e","type":"AWS EC2","z":"54477b72.9b0d74","aws":"90b694364b5c3889","operation":"StartInstances","ReservedInstanceIds":"","TransitGatewayAttachmentId":"","ServiceId":"","VpcEndpointIds":"","Cidr":"","AvailabilityZone":"","Quantity":"","ClientVpnEndpointId":"","VpcId":"","SecurityGroupIds":"","NetworkInterfaceId":"","SubnetId":"","DhcpOptionsId":"","IamInstanceProfile":"","InstanceId":"","RouteTableId":"","Ipv6CidrBlock":"","TransitGatewayRouteTableId":"","Groups":"","InternetGatewayId":"","DeviceIndex":"","Device":"","VolumeId":"vol-005ee787ab2419e7b","VpnGatewayId":"","TargetNetworkCidr":"","GroupId":"","Storage":"","BundleId":"","CapacityReservationId":"","ConversionTaskId":"","ExportTaskId":"","ReservedInstancesListingId":"","SpotFleetRequestIds":"","TerminateInstances":"","SpotInstanceRequestIds":"","ProductCode":"","SourceFpgaImageId":"","SourceRegion":"","Name":"","SourceImageId":"","SourceSnapshotId":"","InstanceType":"","InstancePlatform":"","InstanceCount":"","ClientCidrBlock":"","ServerCertificateArn":"","AuthenticationOptions":"","ConnectionLogOptions":"","DestinationCidrBlock":"","TargetVpcSubnetId":"","BgpAsn":"","Type":"","DhcpConfigurations":"","LaunchTemplateConfigs":"","TargetCapacitySpecification":"","ResourceIds":"","ResourceType":"","TrafficType":"","InputStorageLocation":"","ExportToS3Task":"","TargetEnvironment":"","KeyName":"","LaunchTemplateName":"","LaunchTemplateData":"","LocalGatewayRouteTableId":"","LocalGatewayVirtualInterfaceGroupId":"","PrefixListName":"","MaxEntries":"","AddressFamily":"","AllocationId":"","Egress":"","NetworkAclId":"","Protocol":"","RuleAction":"","RuleNumber":"","Source":"","Destination":"","ClientToken":"","Permission":"","PriceSchedules":"","ReservedInstancesId":"","Description":"","GroupName":"","InstanceSpecification":"","Bucket":"","CidrBlock":"","Resources":"","Tags":"","TrafficMirrorFilterId":"","TrafficDirection":"","SourceCidrBlock":"","TrafficMirrorTargetId":"","SessionNumber":"","TransportTransitGatewayAttachmentId":"","Options":"","PeerAddress":"","InsideCidrBlocks":"","TransitGatewayId":"","PeerTransitGatewayId":"","PeerAccountId":"","PeerRegion":"","PrefixListId":"","SubnetIds":"","ServiceName":"","ConnectionNotificationArn":"","ConnectionEvents":"","CustomerGatewayId":"","VpnConnectionId":"","CarrierGatewayId":"","EgressOnlyInternetGatewayId":"","FleetIds":"","FlowLogIds":"","FpgaImageId":"","Versions":"","LocalGatewayRouteTableVpcAssociationId":"","NatGatewayId":"","NetworkInsightsAnalysisId":"","NetworkInsightsPathId":"","NetworkInterfacePermissionId":"","ReservedInstancesIds":"","SnapshotId":"","TrafficMirrorFilterRuleId":"","TrafficMirrorSessionId":"","TransitGatewayConnectPeerId":"","TransitGatewayMulticastDomainId":"","ConnectionNotificationIds":"","ServiceIds":"","VpcPeeringConnectionId":"","ImageId":"","MaxResults":"","FleetId":"","StartTime":"","Attribute":"","PrincipalArn":"","FirstSlotStartTimeRange":"","Recurrence":"","SpotFleetRequestId":"","AttachmentId":"","AvailabilityZones":"","SourceSnapshotIds":"","GatewayId":"","AssociationId":"","DiskImageFormat":"","S3ExportLocation":"","S3Bucket":"","PoolId":"","InstanceFamily":"","HostIdSet":"","OfferingId":"","CertificateRevocationList":"","Platform":"","PublicKeyMaterial":"","Image":"","Volume":"","OptInStatus":"","CpuCredits":"","KmsKeyId":"","HostIds":"","Resource":"","UseLongIds":"","CapacityReservationSpecification":"","InstanceCreditSpecifications":"","InstanceEventId":"","NotBefore":"","TargetConfigurations":"","VpcEndpointId":"","ConnectionNotificationId":"","InstanceTenancy":"","VpnTunnelOutsideIpAddress":"","TunnelOptions":"","InstanceIds":"","PublicIp":"","ReservedInstancesOfferingId":"","PurchaseRequests":"","Instances":"","ReasonCodes":"","Status":"impaired","SpotFleetRequestConfig":"","PreviousVersion":"","CurrentVersion":"","MaxCount":"","MinCount":"","LaunchSpecification":"","ScheduledInstanceId":"","Filters":"","Ipv6Addresses":"","PrivateIpAddresses":"","IpPermissions":"","name":"Start","x":420,"y":310,"wires":[["278f47f227d03215"],["278f47f227d03215"]]},{"id":"278f47f227d03215","type":"debug","z":"54477b72.9b0d74","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":640,"y":310,"wires":[]},{"id":"90b694364b5c3889","type":"amazon config","name":"AWS","region":"ca-central-1","proxyRequired":false,"proxy":""}]

@Daniel-t
Copy link
Owner

Daniel-t commented Dec 2, 2021

Sorry I'm away at the moment, and dont have a node-red instance available. Can you wire the inject into a debug node (configured to show the whole message) and paste the output.

@JohnnyPicnic
Copy link
Author

msg : Object
object
_msgid: "a97e3cd9f65ee48a"
payload: ""
topic: ""
InstanceIds: "[i-030fa455efd7291aa]"

@JohnnyPicnic
Copy link
Author

JohnnyPicnic commented Dec 4, 2021

Ah I got it.
Modified this from the Node-Red forum.
In a function node:
`var myArray = context.get("myArray");

if(!myArray) {
console.log("Set the array on context memory");
context.set("myArray", []);
myArray = context.get("myArray");
}

myArray.push(msg.payload);
msg.InstanceIds = myArray;
return msg;`

And injected my instance id as the msg.payload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants