bash-my-aws / bash-my-aws

Bash-my-AWS provides simple but powerful CLI commands for managing AWS resources

Home Page:https://bash-my-aws.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error with command: stack-instances

mike-mosher opened this issue · comments

$ stacks
test CREATE_COMPLETE 2018-08-29T20:45:25.962Z None

$ stack-instances test
An error occurred (InvalidInstanceID.Malformed) when calling the DescribeInstances operation: Invalid id: "AWS::EC2::Instance"

Any thoughts or comments on this?

Sorry for delay.

Are you able to reproduce?
If so, could you post:

  • OS
  • bash version
  • a simple stack template
  • output of command after running set -x
  • OS: macOS Sierra, 10.12.6

  • bash version:

$ /bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)
  • a simple stack template:
# Use public SSM Parameter for latest Amazon Linux 2 AMI ID
Parameters:
  LatestAmiId:
    Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
    Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2'

Resources:
 Instance:
    Type: 'AWS::EC2::Instance'
    Properties:
      ImageId: !Ref LatestAmiId
  • output of command after running set -x:

This should be enough to show the issue:

 $ stack-instances test
+ stack-instances test
++ stack-resources test
++ grep AWS::EC2::Instance
++ cut -f1
+++ __bma_read_inputs test
+++ sed -E 's/\ +$//'
++++ __bma_read_stdin
++++ [[ -t 0 ]]
+++ sed -E 's/^\ +//'
+++ echo test
++ local inputs=test
+++ _stack_name_arg test
+++ local 'regex_role_arn_or_capabilities=^\-\-role\-arn=.*|^\-\-capabilities=.*'
+++ [[ test =~ ^\-\-role\-arn=.*|^\-\-capabilities=.* ]]
+++ basename test
+++ sed 's/[.].*$//'
++ local stack=test
++ [[ -z test ]]
++ aws cloudformation describe-stack-resources --stack-name test --query 'StackResources[].[ PhysicalResourceId, ResourceType ]' --output text
++ column '-s	' -t
+ local 'instance_ids=i-1234567890abcdefg  AWS::EC2::Instance'
+ [[ -n i-1234567890abcdefg  AWS::EC2::Instance ]]
+ instances i-1234567890abcdefg AWS::EC2::Instance
++ __bma_read_inputs i-1234567890abcdefg AWS::EC2::Instance
++ sed -E 's/\ +$//'
++ sed -E 's/^\ +//'
+++ __bma_read_stdin
+++ [[ -t 0 ]]
++ echo i-1234567890abcdefg AWS::EC2::Instance
+ local 'instance_ids=i-1234567890abcdefg AWS::EC2::Instance'
+ column '-s	' -t
++ [[ -n i-1234567890abcdefg AWS::EC2::Instance ]]
++ echo --instance-ids i-1234567890abcdefg AWS::EC2::Instance
+ aws ec2 describe-instances --instance-ids i-1234567890abcdefg AWS::EC2::Instance --query '
      Reservations[].Instances[][
        InstanceId,
        ImageId,
        InstanceType,
        State.Name,
        [Tags[?Key=='\''Name'\''].Value][0][0],
        LaunchTime,
        Placement.AvailabilityZone,
        VpcId
      ]' --output text

An error occurred (InvalidInstanceID.Malformed) when calling the DescribeInstances operation: Invalid id: "AWS::EC2::Instance"

Thanks Mike, I love your simple CF!

I've not got a Mac handy but suspect ditching cut for awk will fix. Would you mind testing #157 ?

Nice! That did it. Please let me know when you merge that one in.