GithubHelp home page GithubHelp logo

ec2-launch-api's Introduction

Ec2 Launch Api

Note

Your credentials do not get stored anywhere in this application. This api interacts with the nodejs aws-sdk directly and creates a new ec2 class instance on each request.

Features

  • Manage Ec2 Instances
  • Launch Instances
  • Stop Instances
  • Delete Instances

Api Base Route: https://ec2-launch-api.herokuapp.com/

All requests use the following header:

Content-Type: 'application/json'

Launching an Ec2 Instance

[POST] {BasePath}/api/instances/launch?secretKey={}&keyId={}&region={}&count={}
Content-Type: 'application/json'

Params:

secretKey:Aws Secret Key
keyId: Aws Access Key Id
region: Aws Region Ex: {us-east-2}
[Optional] count: Max Number of instances to launch , if omitted defaults to 1

Body:

{
    imageId: 'ami-****',
    instanceType: 't2.micro',
    keyName: '***', //Ssh Key used to connect to instance
    subnetId: 'subnet-***',
    sgIds:['sg-****'],
    tags: [
    {
      ResourceType: "instance",
      Tags: [
        {
          Key: "Name",
          Value: "Ec2 Instance Name"
        }
      ]
    }
  ]
}

Requests to this endpoint will return an array of ids for all launched instances.

Example:

{
  "instances": ["i-123445"]
}

Checking status of one or more instances

Instance Ids should be added in the query as comma seperated values.

Will only return a status once the instance is live. If instance is not live, this endpoint will return an empty array.

[GET] {{BasePath}}/api/instances/status?secretKey={}&keyId={}&region={}&instanceIds=id1,id2,id3'
Content-Type: 'application/json'

Response:

{
  "status": [
    {
      "AvailabilityZone": "region",
      "Events": [],
      "InstanceId": "i-******",
      "InstanceState": {
        "Code": 16,
        "Name": "running"
      },
      "InstanceStatus": {
        "Details": [
          {
            "Name": "reachability",
            "Status": "passed"
          }
        ],
        "Status": "ok"
      },
      "SystemStatus": {
        "Details": [
          {
            "Name": "reachability",
            "Status": "passed"
          }
        ],
        "Status": "ok"
      }
    }
  ]
}

Checking the details of one or more instances

Instance Ids should be added in the query as comma seperated values.

[GET] {{BasePath}}/api/instances/details?secretKey={}&keyId={}&region={}&instanceIds=id1,id2,id3'
Content-Type: 'application/json'

Response:

{
    "details":  "Reservations": [
      {
        "Groups": [],
        "Instances": [
          {
            "AmiLaunchIndex": 0,
            "ImageId": "ami-*****",
            "InstanceId": "i-****",
            "InstanceType": "t2.micro",
            "KeyName": "*****",
            "LaunchTime": "2020-04-11T22:39:13.000Z",
            "Monitoring": {
              "State": "disabled"
            },
            "Placement": {
              "AvailabilityZone": "Region",
              "GroupName": "",
              "Tenancy": "default"
            },
            "PrivateDnsName": "****.ec2.internal",
            "PrivateIpAddress": "********",
            "ProductCodes": [],
            "PublicDnsName": "****.compute-1.amazonaws.com",
            "PublicIpAddress": "****",
            "State": {
              "Code": 16,
              "Name": "running"
            },
            "StateTransitionReason": "",
            "SubnetId": "subnet-***",
            "VpcId": "vpc-*****",
            "Architecture": "x86_64",
            "BlockDeviceMappings": [
              {
                "DeviceName": "/dev/sda1",
                "Ebs": {
                  "AttachTime": "2020-04-11T22:39:14.000Z",
                  "DeleteOnTermination": true,
                  "Status": "attached",
                  "VolumeId": "vol-****"
                }
              }
            ],
            "ClientToken": "",
            "EbsOptimized": false,
            "EnaSupport": true,
            "Hypervisor": "xen",
            "ElasticGpuAssociations": [],
            "ElasticInferenceAcceleratorAssociations": [],
            "NetworkInterfaces": [
              {
                "Association": {
                  "IpOwnerId": "amazon",
                  "PublicDnsName": "****.compute-1.amazonaws.com",
                  "PublicIp": "****"
                },
                "Attachment": {
                  "AttachTime": "2020-04-11T22:39:13.000Z",
                  "AttachmentId": "eni-attach-****",
                  "DeleteOnTermination": true,
                  "DeviceIndex": 0,
                  "Status": "attached"
                },
                "Description": "",
                "Groups": [
                  {
                    "GroupName": "****",
                    "GroupId": "*****"
                  }
                ],
                "Ipv6Addresses": [],
                "MacAddress": "***",
                "NetworkInterfaceId": "eni-****",
                "OwnerId": "****",
                "PrivateDnsName": "****.ec2.internal",
                "PrivateIpAddress": "****",
                "PrivateIpAddresses": [
                  {
                    "Association": {
                      "IpOwnerId": "amazon",
                      "PublicDnsName": "****.compute-1.amazonaws.com",
                      "PublicIp": "****"
                    },
                    "Primary": true,
                    "PrivateDnsName": "***.ec2.internal",
                    "PrivateIpAddress": "****"
                  }
                ],
                "SourceDestCheck": true,
                "Status": "in-use",
                "SubnetId": "***",
                "VpcId": "****",
                "InterfaceType": "interface"
              }
            ],
            "RootDeviceName": "/dev/sda1",
            "RootDeviceType": "ebs",
            "SecurityGroups": [
              {
                "GroupName": "***",
                "GroupId": "****"
              }
            ],
            "SourceDestCheck": true,
            "Tags": [
              {
                "Key": "Name",
                "Value": "Ec2 Instance Name"
              }
            ],
            "VirtualizationType": "hvm",
            "CpuOptions": {
              "CoreCount": 1,
              "ThreadsPerCore": 1
            },
            "CapacityReservationSpecification": {
              "CapacityReservationPreference": "open"
            },
            "HibernationOptions": {
              "Configured": false
            },
            "Licenses": [],
            "MetadataOptions": {
              "State": "applied",
              "HttpTokens": "optional",
              "HttpPutResponseHopLimit": 1,
              "HttpEndpoint": "enabled"
            }
          }
        ],
        "OwnerId": "*****",
        "ReservationId": "****"
      }
    ]
  }
}

Stopping Instances

[POST] {{BasePath}}/api/instances/stop?secretKey={}&keyId={}&region={}
Content-Type: 'application/json'

Send desired instance ids to stop in the request body.

Request Body:

{
  "instanceIds": ["i-****", "i-****]
}

Send desired instance ids to stop in the request body.

Response:

{
  "stopStatus": {
    "StoppingInstances": [
      {
        "CurrentState": {
          "Code": 64,
          "Name": "stopping"
        },
        "InstanceId": "i-*****",
        "PreviousState": {
          "Code": 16,
          "Name": "running"
        }
      }
    ]
  }
}

Destroying Instances

[POST] {{BasePath}}/api/instances/destroy?secretKey={}&keyId={}&region={}
Content-Type: 'application/json'

Send desired instance ids to destroy in the request body.

Request Body:

{
  "instanceIds": ["i-****", "i-****]
}

Response:

{
  "destroyed": {
    "TerminatingInstances": [
      {
        "CurrentState": {
          "Code": 48,
          "Name": "terminated"
        },
        "InstanceId": "i-****",
        "PreviousState": {
          "Code": 80,
          "Name": "stopped"
        }
      }
    ]
  }
}

ec2-launch-api's People

Contributors

anpato avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.