ec2util

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2019 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePEMAndParseCertificate

func DecodePEMAndParseCertificate(certificate string) (*x509.Certificate, error)

DecodePEMAndParseCertificate decodes the PEM encoded certificate and parses it into a x509 cert.

func GetIamInstanceProfileARN

func GetIamInstanceProfileARN(output *ec2.DescribeInstancesOutput) (string, error)

GetIamInstanceProfileARN extracts the ARN from the output of a call to DescribeInstances. The ARN is expected to be non-empty.

func GetPublicIPAddress

func GetPublicIPAddress(output *ec2.DescribeInstancesOutput) (string, error)

GetPublicIPAddress extracts the public IP address from the output of a call to DescribeInstances. The response is expected to be non-empty if the instance has a public IP and empty ("") if the instance is private.

func ValidateInstance

func ValidateInstance(output *ec2.DescribeInstancesOutput, doc IdentityDocument, remoteAddr string) (role string, err error)

ValidateInstance checks if an EC2 instance exists and it has the expected IP. It returns the name of the instance profile (the IAM role).

Note that this validation will not work for NATed VMs.

Types

type IdentityDocument

type IdentityDocument struct {
	InstanceID  string    `json:"instanceId,omitempty"`
	AccountID   string    `json:"accountId,omitempty"`
	Region      string    `json:"region,omitempty"`
	PendingTime time.Time `json:"pendingTime,omitempty"`
}

func ParseAndVerifyIdentityDocument

func ParseAndVerifyIdentityDocument(pkcs7b64 string) (*IdentityDocument, string, error)

ParseAndVerifyIdentityDocument parses and checks and identity document in PKCS#7 format. Only some relevant fields are returned.

Jump to

Keyboard shortcuts

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