Skip to content

Testcontainers wrapper for the Instance Metadata Mock (imds-mock) tool. Quickly and easily simulate IMDS for localised testing

License

Notifications You must be signed in to change notification settings

purpleclay/testcontainers-imds

Repository files navigation

testcontainers-imds

Build status License MIT Go Report Card Go Version DeepSource

Testcontainers wrapper for the Instance Metadata Mock (imds-mock) tool. Quickly and easily simulate the Amazon Instance Metadata Service (IMDS) for localised testing.

Quick Start

Import the library into your project:

go get github.com/purpleclay/testcontainers-imds

Then write your first test:

package imds_test

import (
    "context"
    "testing"

    imds "github.com/purpleclay/testcontainers-imds"
    "github.com/stretchr/testify/assert"
    "github.com/stretchr/testify/require"
)

func TestInstanceMetadata(t *testing.T) {
    ctx := context.Background()

    container, err := imds.Start(ctx)
    require.NoError(t, err)
    defer container.Terminate(ctx)

    ipv4, _, _ := container.Get(imds.PathLocalIPv4)

    assert.Equal(t, imds.ValueLocalIPv4, ipv4)
}

If you need more examples, take a look here.

About

Testcontainers wrapper for the Instance Metadata Mock (imds-mock) tool. Quickly and easily simulate IMDS for localised testing

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages