Help us shape the future of Go! Take the 2026 Go Developer Survey

ec2meta

package module
v0.0.0-...-6f99a7f Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2019 License: MIT Imports: 6 Imported by: 2

README

go-ec2meta

license

This Library is to get metadata for EC2 Instances using Golang.
It can get information like public-ip, hostname, mac .. and so on, if this machine is EC2 instance in AWS.
Maybe you are useful when your application in Docker Container is getting IP information(host machine IP .. and so on).

Usage

import  "github.com/gjbae1212/go-ec2meta"

hosts, err := ec2meta.PublicHostname()
ips, err := ec2meta.PublicIPV4()

// and so on.

Method

method name description
Hostname hostname
LocalHostname local hostname
LocalIPV4 local ip information(V4)
PublicHostname public hostname
PublicIPV4 public ip information(V4)
Mac instance mac address

Features (TODO)

  • hostname
  • local-hostname
  • local-ipv4
  • public-hostname
  • public-ipv4
  • mac
  • ami-id
  • ami-launch-index
  • ami-manifest-path
  • instance-action
  • instance-id
  • instance-type
  • profile
  • reservation-id
  • block-device-mapping/ (multiple option)
  • events/ (multiple option)
  • iam/ (multiple option)
  • metrics/ (multiple option)
  • network/ (multiple option)
  • placement/ (multiple option)
  • public-keys/ (multiple option)
  • security-groups (multiple option)
  • services/ (multiple option)

LICENSE

This project is following The MIT.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnAvailableService = errors.New("[err] this machine isn't used to metadata service, maybe its machine not in AWS.")
	ErrNotFound           = errors.New("[err] not found resource.")
)

Functions

func CanLookup

func CanLookup() bool

CanLookup is to check whether this machine can access a server serving metadata in AWS.

func Hostname

func Hostname() ([]string, error)

Hostname is to get hostname from this instance.

func LocalHostname

func LocalHostname() ([]string, error)

LocalHostname is to get local hostname from this instance.

func LocalIPV4

func LocalIPV4() ([]string, error)

LocalIPV4 is to get local ipv4 from this instance.

func Mac

func Mac() ([]string, error)

Mac is to get mac address from this instance.

func PublicHostname

func PublicHostname() ([]string, error)

PublicHostname is to get public hostname from this instance.

func PublicIPV4

func PublicIPV4() ([]string, error)

PublicIPV4 is to get public ipv4 from this instance.

Types

This section is empty.

Jump to

Keyboard shortcuts

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