aws

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MetadataURL is the endpoint to make requests to fetch instance metadata from
	MetadataURL = "http://169.254.169.254"
	Version     = func() string { return fmt.Sprintf("%s/latest", MetadataURL) }
	APIToken    = func() string { return fmt.Sprintf("%s/api/token", Version()) }

	MetadataIdentity          = func() string { return fmt.Sprintf("%s/dynamic/instance-identity/document", Version()) }
	MetadataIdentitySignature = func() string { return fmt.Sprintf("%s/dynamic/instance-identity/pkcs7", Version()) }
)
View Source
var AWSCertificates = map[string]string{
	"Global": `-----BEGIN CERTIFICATE-----
MIIC7TCCAq0CCQCWukjZ5V4aZzAJBgcqhkjOOAQDMFwxCzAJBgNVBAYTAlVTMRkw
FwYDVQQIExBXYXNoaW5ndG9uIFN0YXRlMRAwDgYDVQQHEwdTZWF0dGxlMSAwHgYD
VQQKExdBbWF6b24gV2ViIFNlcnZpY2VzIExMQzAeFw0xMjAxMDUxMjU2MTJaFw0z
ODAxMDUxMjU2MTJaMFwxCzAJBgNVBAYTAlVTMRkwFwYDVQQIExBXYXNoaW5ndG9u
IFN0YXRlMRAwDgYDVQQHEwdTZWF0dGxlMSAwHgYDVQQKExdBbWF6b24gV2ViIFNl
cnZpY2VzIExMQzCCAbcwggEsBgcqhkjOOAQBMIIBHwKBgQCjkvcS2bb1VQ4yt/5e
ih5OO6kK/n1Lzllr7D8ZwtQP8fOEpp5E2ng+D6Ud1Z1gYipr58Kj3nssSNpI6bX3
VyIQzK7wLclnd/YozqNNmgIyZecN7EglK9ITHJLP+x8FtUpt3QbyYXJdmVMegN6P
hviYt5JH/nYl4hh3Pa1HJdskgQIVALVJ3ER11+Ko4tP6nwvHwh6+ERYRAoGBAI1j
k+tkqMVHuAFcvAGKocTgsjJem6/5qomzJuKDmbJNu9Qxw3rAotXau8Qe+MBcJl/U
hhy1KHVpCGl9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8Qe+MBcJl/U
hhy1KHVpCGl9fueQ2s6IL0CaO/buycU1CiYQk40KNHCcHfNiZbdlx1E9rpUp7bnF
lRa2v1ntMX3caRVDdbtPEWmdxSCYsYFDk4mZrOLBA4GEAAKBgEbmeve5f8LIE/Gf
MNmP9CM5eovQOGx5ho8WqD+aTebs+k2tn92BBPqeZqpWRa5P/+jrdKml1qx4llHW
MXrs3IgIb6+hUIB+S8dz8/mmO0bpr76RoZVCXYab2CZedFut7qc3WUH9+EUAH5mw
vSeDCOUMYQR7R9LINYwouHIziqQYMAkGByqGSM44BAMDLwAwLAIUWXBlk40xTwSw
7HX32MxXYruse9ACFBNGmdX2ZBrVNGrN9N2f6ROk0k9K
-----END CERTIFICATE-----`,
}

AWSCertificates represent the certificates in many regions.

View Source
var ErrNotWhitelisted = errors.New("not whitelisted")
View Source
var TokenHeader = &http.Header{
	"X-aws-ec2-metadata-token-ttl-seconds": []string{"21600"},
}

Functions

func CheckWhitelist

func CheckWhitelist(value string, whitelist []string) bool

func GetCertificates

func GetCertificates(certs map[string]string) ([]*x509.Certificate, error)

GetCertificates returns the given certificates as a certificate pool

func GetMetadataHeader

func GetMetadataHeader(token string) http.Header

Types

type InstanceIdentityDocument

type InstanceIdentityDocument struct {
	DevpayProductCodes      []string  `json:"devpayProductCodes"`
	MarketplaceProductCodes []string  `json:"marketplaceProductCodes"`
	AvailabilityZone        string    `json:"availabilityZone"`
	PrivateIP               string    `json:"privateIp"`
	InstanceID              string    `json:"instanceId"`
	BillingProducts         []string  `json:"billingProducts"`
	AccountID               string    `json:"accountId"`
	ImageID                 string    `json:"imageId"`
	PendingTime             time.Time `json:"pendingTime"`
	Architecture            string    `json:"architecture"`
	KernelID                string    `json:"kernelId"`
	RamdiskID               string    `json:"ramdiskId"`
	Region                  string    `json:"region"`
}

InstanceIdentityDocument represents the AWS Instance Identity Document structure.

type InstanceIdentityPassword

type InstanceIdentityPassword struct {
	Payload   []byte
	Signature []byte
}

InstanceIdentityPassword represents the password struct to encode into the ProvideResponse

func (*InstanceIdentityPassword) Decode

func (iip *InstanceIdentityPassword) Decode(s string) error

Decode returns a gob encoded representation of the Instance Identity Password

func (*InstanceIdentityPassword) Encode

func (iip *InstanceIdentityPassword) Encode() (string, error)

Encode returns a gob encoded representation of the Instance Identity Password

Jump to

Keyboard shortcuts

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