iann0036 / AWSConsoleRecorder

Records actions made in the AWS Management Console and outputs the equivalent CLI/SDK commands and CloudFormation/Terraform templates.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

All parameters not captured on ec2.RunInstances

jbananas opened this issue · comments

Describe the bug
Recorder is not capturing all parameters entered during recording.

Related Mapping
ec2.RunInstances

Related Language
Only CLI and Python tested

To Reproduce
Steps to reproduce the behavior:

  1. Start recorder
  2. From EC2 Dashboard click Launch Instance
  3. Select default amazon linux 2 ami
  4. Select default t2.micro instance type
  5. Change default VPC/subnet to anything else.
  6. Next, Next, Next
  7. On security group setup page, choose any existing security group.
  8. Next next finish through wizard

Expected behavior
Generated CLI/SDK commands should contain non-default VPC/subnet and security group parameters. They do not.

Using above steps, generated CLI command is as follows. It does not contain a --subnet-id parameter or a --security-group-ids parameter as expected:

aws ec2 run-instances --image-id "ami-009d6802948d06e52" --count 1 --key-name "mykey" --instance-type "t2.micro" --placement '{"Tenancy":"default"}' --monitoring '{"Enabled":false}' --enable-api-termination --instance-initiated-shutdown-behavior "stop" --credit-specification '{"CpuCredits":"standard"}' --no-ebs-optimized --block-device-mappings '[{"DeviceName":"/dev/xvda","Ebs":{"VolumeSize":8,"DeleteOnTermination":true,"VolumeType":"gp2"}}]' --region us-east-1

Recorder-generated python command is as follows. Likewise, it does not contain SubnetId or SecurityGroupIds arguments as expected:

response = ec2_client.run_instances(
    ImageId='ami-009d6802948d06e52',
    MaxCount=1,
    MinCount=1,
    KeyName='mykey',
    InstanceType='t2.micro',
    Placement={
        Tenancy='default'
    },
    Monitoring={
        Enabled=False
    },
    DisableApiTermination=False,
    InstanceInitiatedShutdownBehavior='stop',
    CreditSpecification={
        CpuCredits='standard'
    },
    EbsOptimized=False,
    BlockDeviceMapping=[
        {
            DeviceName='/dev/xvda',a
            Ebs={
                VolumeSize=8,
                DeleteOnTermination=True,
                VolumeType='gp2'
            }
        }
    ]
)

Added NetworkInterfaces (and some others) which should capture the subnet and security groups.

Thanks for raising!