ec2

package
v0.75.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

Amazon Elastic Compute service

This service is github.com/aws/aws-sdk-go/service/ec2.EC2 proxy

To check all supported method run

    endly -s="aws/ec2"

To check method contract run endly -s="aws/ec2" -a=methodName

    endly -s="aws/ec2" -a='stopInstances'
Usage:
Starting instance

@start.yaml

init:
  instanceId: i-0064b6c35XXXXX
pipeline:
  start:
    info:
      action: aws/ec2:describeInstances
      logging: false
      credentials: aws
      instanceids:
       - $instanceId

    print:
      action: print
      message: Instance $instanceId is  $info.Reservations[0].Instances[0].State.Name

    check:
      when: $info.Reservations[0].Instances[0].State.Name = 'running'
      action: exit

    instanceUp:
      when: $info.Reservations[0].Instances[0].State.Name = 'stopped'
      action: aws/ec2:startInstances
      logging: false
      instanceids:
        - $instanceId

    waitForStart:
      action: nop
      logging: false
      sleepTimeMs: 5000

    gotoStart:
      action: goto
      task: start

Stop instance

@stop.yaml

init:
  instanceId: i-0064b6c35XXXXX
pipeline:
  stop:
    info:
      action: aws/ec2:describeInstances
      logging: false
      credentials: aws
      instanceids:
        - $instanceId

    print:
      action: print
      message: Instance $instanceId is  $info.Reservations[0].Instances[0].State.Name

    check:
      when: $info.Reservations[0].Instances[0].State.Name = 'stopped'
      action: exit

    instanceDown:
      when: $info.Reservations[0].Instances[0].State.Name = 'running'
      action: aws/ec2:stopInstances
      logging: false
      instanceids:
        - $instanceId
    waitForStop:
      action: nop
      logging: false
      sleepTimeMs: 5000
    gotoStop:
      action: goto
      task: stop
Getting instance by tag name

endly -r=instance

@instance.yaml

pipeline:
  instanceInfo:
    action: aws/ec2:getInstance
    credentials: aws-e2e
    '@name': e2e-aero
  info:
    action: print
    message: $AsJSON($instanceInfo)
Getting vpc by tag name
pipeline:
  vpcInfo:
    action: aws/ec2:getVpc
    credentials: aws-e2e
    '@name': aero
  info:
    action: print
    message: $AsJSON($vpcInfo)
Getting vpcConifg

endly -r=vpc_config

@vpc_config

pipeline:
  byVpc:
    vpcConfigInfo1:
      action: aws/ec2:getVpcConfig
      credentials: aws-e2e
      vpc:
        name: aero
    info:
      action: print
      message: $AsJSON($vpcConfigInfo1)

  byInstance:
    vpcConfigInfo2:
      action: aws/ec2:getVpcConfig
      credentials: aws-e2e
      instance:
        name: e2e-aero
    info:
      action: print
      message: $AsJSON($vpcConfigInfo2)

Documentation

Index

Constants

View Source
const (
	//ServiceID aws iam service id.
	ServiceID = "aws/ec2"
)

Variables

This section is empty.

Functions

func GetClient

func GetClient(context *endly.Context) (*ec2.EC2, error)

GetClient returns ec2 client from context

func New

func New() endly.Service

New creates a new EC2 service.

Types

type Filter

type Filter struct {
	ID                  string `description:"if specified SessionID match"`
	VpcID               string
	Name                string            `description:"name is a tags.Name helper"`
	Tags                map[string]string `description:"matching tags"`
	SubnetExclusionTags map[string]string `description:"if specied exclude matched subnet"`
}

Filter represents a filter

func (*Filter) Init

func (f *Filter) Init() error

Init initialises filter tags

type GetInstanceInput

type GetInstanceInput struct {
	Filter
}

GetInstanceInput represents get instance request

type GetInstanceOutput

type GetInstanceOutput struct {
	*ec2.Instance
}

GetInstanceInput represents get instance response

type GetSecurityGroupInput

type GetSecurityGroupInput struct {
	Filter
}

GetSecurityGroupInput represents request

type GetSecurityGroupsOutput

type GetSecurityGroupsOutput struct {
	Groups []*ec2.SecurityGroup
}

GetSecurityGroupsOutput represents response

type GetSubnetsInput

type GetSubnetsInput struct {
	Filter
}

GetSubnetsInput represents request

type GetSubnetsOutput

type GetSubnetsOutput struct {
	Subnets []*ec2.Subnet
}

GetSubnetsOutput represents response

type GetVpcConfigInput

type GetVpcConfigInput struct {
	Vpc      *Filter
	Instance *Filter
}

GetVpcConfigInput represents get vpc config request for iter vpc or instance name

func (*GetVpcConfigInput) Init

func (i *GetVpcConfigInput) Init() error

Init initializes request

type GetVpcConfigOutput

type GetVpcConfigOutput struct {
	VpcID *string
	// A list of VPC security groups IDs.
	SecurityGroupIds []*string `type:"list"`

	// A list of VPC subnet IDs.
	SubnetIds []*string `type:"list"`
}

GetVpcConfigInput represents get vpc config response

type GetVpcInput

type GetVpcInput struct {
	Filter
}

GetVpcInput represents vpc request

type GetVpcOutput

type GetVpcOutput struct {
	*ec2.Vpc
}

GetVpcInput represents vpc response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL