HCP

Community
Package contributed by a community member
v0.1.11 published on Monday, Jul 25, 2022 by Grapl Security

getPackerImage

The Packer Image data source iteration gets the most recent iteration (or build) of an image, given an iteration id or a channel.

Example Usage

Single image sourcing

using Pulumi;
using Hcp = Pulumi.Hcp;

class MyStack : Stack
{
    public MyStack()
    {
        var baz = Output.Create(Hcp.GetPackerImage.InvokeAsync(new Hcp.GetPackerImageArgs
        {
            BucketName = "hardened-ubuntu-16-04",
            CloudProvider = "aws",
            Channel = "production",
            Region = "us-east-1",
        }));
        this.Packer_registry_ubuntu_east_1 = baz.Apply(baz => baz.CloudImageId);
    }

    [Output("packer-registry-ubuntu-east-1")]
    public Output<string> Packer_registry_ubuntu_east_1 { get; set; }
}
package main

import (
	"github.com/grapl-security/pulumi-hcp/sdk/go/hcp"
	"github.com/pulumi/pulumi-hcp/sdk/go/hcp"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		baz, err := hcp.GetPackerImage(ctx, &GetPackerImageArgs{
			BucketName:    "hardened-ubuntu-16-04",
			CloudProvider: "aws",
			Channel:       pulumi.StringRef("production"),
			Region:        "us-east-1",
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("packer-registry-ubuntu-east-1", baz.CloudImageId)
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.hcp.HcpFunctions;
import com.pulumi.hcp.inputs.GetPackerImageArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var baz = HcpFunctions.getPackerImage(GetPackerImageArgs.builder()
            .bucketName("hardened-ubuntu-16-04")
            .cloudProvider("aws")
            .channel("production")
            .region("us-east-1")
            .build());

        ctx.export("packer-registry-ubuntu-east-1", baz.applyValue(getPackerImageResult -> getPackerImageResult.cloudImageId()));
    }
}
import pulumi
import pulumi_hcp as hcp

baz = hcp.get_packer_image(bucket_name="hardened-ubuntu-16-04",
    cloud_provider="aws",
    channel="production",
    region="us-east-1")
pulumi.export("packer-registry-ubuntu-east-1", baz.cloud_image_id)
import * as pulumi from "@pulumi/pulumi";
import * as hcp from "@pulumi/hcp";

export = async () => {
    const baz = await hcp.getPackerImage({
        bucketName: "hardened-ubuntu-16-04",
        cloudProvider: "aws",
        channel: "production",
        region: "us-east-1",
    });
    const packer_registry_ubuntu_east_1 = baz.cloudImageId;
    return {
        "packer-registry-ubuntu-east-1": packer_registry_ubuntu_east_1,
    };
}
variables:
  baz:
    Fn::Invoke:
      Function: hcp:getPackerImage
      Arguments:
        bucketName: hardened-ubuntu-16-04
        cloudProvider: aws
        channel: production
        region: us-east-1
outputs:
  packer-registry-ubuntu-east-1: ${baz.cloudImageId}

Multiple image sourcing from a single iteration

using Pulumi;
using Hcp = Pulumi.Hcp;

class MyStack : Stack
{
    public MyStack()
    {
        var hardened_source = Output.Create(Hcp.GetPackerIteration.InvokeAsync(new Hcp.GetPackerIterationArgs
        {
            BucketName = "hardened-ubuntu-16-04",
            Channel = "production",
        }));
        var foo = hardened_source.Apply(hardened_source => Output.Create(Hcp.GetPackerImage.InvokeAsync(new Hcp.GetPackerImageArgs
        {
            BucketName = "hardened-ubuntu-16-04",
            CloudProvider = "aws",
            IterationId = hardened_source.Ulid,
            Region = "us-east-1",
        })));
        var bar = hardened_source.Apply(hardened_source => Output.Create(Hcp.GetPackerImage.InvokeAsync(new Hcp.GetPackerImageArgs
        {
            BucketName = "hardened-ubuntu-16-04",
            CloudProvider = "aws",
            IterationId = hardened_source.Ulid,
            Region = "us-west-1",
        })));
        this.Packer_registry_ubuntu_east_1 = foo.Apply(foo => foo.CloudImageId);
        this.Packer_registry_ubuntu_west_1 = bar.Apply(bar => bar.CloudImageId);
    }

    [Output("packer-registry-ubuntu-east-1")]
    public Output<string> Packer_registry_ubuntu_east_1 { get; set; }
    [Output("packer-registry-ubuntu-west-1")]
    public Output<string> Packer_registry_ubuntu_west_1 { get; set; }
}
package main

import (
	"github.com/grapl-security/pulumi-hcp/sdk/go/hcp"
	"github.com/pulumi/pulumi-hcp/sdk/go/hcp"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		hardened_source, err := hcp.GetPackerIteration(ctx, &GetPackerIterationArgs{
			BucketName: "hardened-ubuntu-16-04",
			Channel:    "production",
		}, nil)
		if err != nil {
			return err
		}
		foo, err := hcp.GetPackerImage(ctx, &GetPackerImageArgs{
			BucketName:    "hardened-ubuntu-16-04",
			CloudProvider: "aws",
			IterationId:   pulumi.StringRef(hardened_source.Ulid),
			Region:        "us-east-1",
		}, nil)
		if err != nil {
			return err
		}
		bar, err := hcp.GetPackerImage(ctx, &GetPackerImageArgs{
			BucketName:    "hardened-ubuntu-16-04",
			CloudProvider: "aws",
			IterationId:   pulumi.StringRef(hardened_source.Ulid),
			Region:        "us-west-1",
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("packer-registry-ubuntu-east-1", foo.CloudImageId)
		ctx.Export("packer-registry-ubuntu-west-1", bar.CloudImageId)
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.hcp.HcpFunctions;
import com.pulumi.hcp.inputs.GetPackerIterationArgs;
import com.pulumi.hcp.inputs.GetPackerImageArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var hardened-source = HcpFunctions.getPackerIteration(GetPackerIterationArgs.builder()
            .bucketName("hardened-ubuntu-16-04")
            .channel("production")
            .build());

        final var foo = HcpFunctions.getPackerImage(GetPackerImageArgs.builder()
            .bucketName("hardened-ubuntu-16-04")
            .cloudProvider("aws")
            .iterationId(hardened_source.ulid())
            .region("us-east-1")
            .build());

        final var bar = HcpFunctions.getPackerImage(GetPackerImageArgs.builder()
            .bucketName("hardened-ubuntu-16-04")
            .cloudProvider("aws")
            .iterationId(hardened_source.ulid())
            .region("us-west-1")
            .build());

        ctx.export("packer-registry-ubuntu-east-1", foo.applyValue(getPackerImageResult -> getPackerImageResult.cloudImageId()));
        ctx.export("packer-registry-ubuntu-west-1", bar.applyValue(getPackerImageResult -> getPackerImageResult.cloudImageId()));
    }
}
import pulumi
import pulumi_hcp as hcp

hardened_source = hcp.get_packer_iteration(bucket_name="hardened-ubuntu-16-04",
    channel="production")
foo = hcp.get_packer_image(bucket_name="hardened-ubuntu-16-04",
    cloud_provider="aws",
    iteration_id=hardened_source.ulid,
    region="us-east-1")
bar = hcp.get_packer_image(bucket_name="hardened-ubuntu-16-04",
    cloud_provider="aws",
    iteration_id=hardened_source.ulid,
    region="us-west-1")
pulumi.export("packer-registry-ubuntu-east-1", foo.cloud_image_id)
pulumi.export("packer-registry-ubuntu-west-1", bar.cloud_image_id)
import * as pulumi from "@pulumi/pulumi";
import * as hcp from "@pulumi/hcp";

export = async () => {
    const hardened-source = await hcp.getPackerIteration({
        bucketName: "hardened-ubuntu-16-04",
        channel: "production",
    });
    const foo = await hcp.getPackerImage({
        bucketName: "hardened-ubuntu-16-04",
        cloudProvider: "aws",
        iterationId: hardened_source.ulid,
        region: "us-east-1",
    });
    const bar = await hcp.getPackerImage({
        bucketName: "hardened-ubuntu-16-04",
        cloudProvider: "aws",
        iterationId: hardened_source.ulid,
        region: "us-west-1",
    });
    const packer_registry_ubuntu_east_1 = foo.cloudImageId;
    const packer_registry_ubuntu_west_1 = bar.cloudImageId;
    return {
        "packer-registry-ubuntu-east-1": packer_registry_ubuntu_east_1,
        "packer-registry-ubuntu-west-1": packer_registry_ubuntu_west_1,
    };
}
variables:
  hardened-source:
    Fn::Invoke:
      Function: hcp:getPackerIteration
      Arguments:
        bucketName: hardened-ubuntu-16-04
        channel: production
  foo:
    Fn::Invoke:
      Function: hcp:getPackerImage
      Arguments:
        bucketName: hardened-ubuntu-16-04
        cloudProvider: aws
        iterationId: ${["hardened-source"].ulid}
        region: us-east-1
  bar:
    Fn::Invoke:
      Function: hcp:getPackerImage
      Arguments:
        bucketName: hardened-ubuntu-16-04
        cloudProvider: aws
        iterationId: ${["hardened-source"].ulid}
        region: us-west-1
outputs:
  packer-registry-ubuntu-east-1: ${foo.cloudImageId}
  packer-registry-ubuntu-west-1: ${bar.cloudImageId}

Using getPackerImage

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getPackerImage(args: GetPackerImageArgs, opts?: InvokeOptions): Promise<GetPackerImageResult>
function getPackerImageOutput(args: GetPackerImageOutputArgs, opts?: InvokeOptions): Output<GetPackerImageResult>
def get_packer_image(bucket_name: Optional[str] = None,
                     channel: Optional[str] = None,
                     cloud_provider: Optional[str] = None,
                     component_type: Optional[str] = None,
                     iteration_id: Optional[str] = None,
                     region: Optional[str] = None,
                     opts: Optional[InvokeOptions] = None) -> GetPackerImageResult
def get_packer_image_output(bucket_name: Optional[pulumi.Input[str]] = None,
                     channel: Optional[pulumi.Input[str]] = None,
                     cloud_provider: Optional[pulumi.Input[str]] = None,
                     component_type: Optional[pulumi.Input[str]] = None,
                     iteration_id: Optional[pulumi.Input[str]] = None,
                     region: Optional[pulumi.Input[str]] = None,
                     opts: Optional[InvokeOptions] = None) -> Output[GetPackerImageResult]
func GetPackerImage(ctx *Context, args *GetPackerImageArgs, opts ...InvokeOption) (*GetPackerImageResult, error)
func GetPackerImageOutput(ctx *Context, args *GetPackerImageOutputArgs, opts ...InvokeOption) GetPackerImageResultOutput

> Note: This function is named GetPackerImage in the Go SDK.

public static class GetPackerImage 
{
    public static Task<GetPackerImageResult> InvokeAsync(GetPackerImageArgs args, InvokeOptions? opts = null)
    public static Output<GetPackerImageResult> Invoke(GetPackerImageInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetPackerImageResult> getPackerImage(GetPackerImageArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: hcp:index/getPackerImage:getPackerImage
  Arguments:
    # Arguments dictionary

The following arguments are supported:

BucketName string
CloudProvider string
Region string
Channel string
ComponentType string
IterationId string
BucketName string
CloudProvider string
Region string
Channel string
ComponentType string
IterationId string
bucketName String
cloudProvider String
region String
channel String
componentType String
iterationId String
bucketName string
cloudProvider string
region string
channel string
componentType string
iterationId string
bucketName String
cloudProvider String
region String
channel String
componentType String
iterationId String

getPackerImage Result

The following output properties are available:

BucketName string
BuildId string
CloudImageId string
CloudProvider string
ComponentType string
CreatedAt string
Id string

The provider-assigned unique ID for this managed resource.

IterationId string
Labels Dictionary<string, object>
OrganizationId string
PackerRunUuid string
ProjectId string
Region string
RevokeAt string
Channel string
BucketName string
BuildId string
CloudImageId string
CloudProvider string
ComponentType string
CreatedAt string
Id string

The provider-assigned unique ID for this managed resource.

IterationId string
Labels map[string]interface{}
OrganizationId string
PackerRunUuid string
ProjectId string
Region string
RevokeAt string
Channel string
bucketName String
buildId String
cloudImageId String
cloudProvider String
componentType String
createdAt String
id String

The provider-assigned unique ID for this managed resource.

iterationId String
labels Map<String,Object>
organizationId String
packerRunUuid String
projectId String
region String
revokeAt String
channel String
bucketName string
buildId string
cloudImageId string
cloudProvider string
componentType string
createdAt string
id string

The provider-assigned unique ID for this managed resource.

iterationId string
labels {[key: string]: any}
organizationId string
packerRunUuid string
projectId string
region string
revokeAt string
channel string
bucket_name str
build_id str
cloud_image_id str
cloud_provider str
component_type str
created_at str
id str

The provider-assigned unique ID for this managed resource.

iteration_id str
labels Mapping[str, Any]
organization_id str
packer_run_uuid str
project_id str
region str
revoke_at str
channel str
bucketName String
buildId String
cloudImageId String
cloudProvider String
componentType String
createdAt String
id String

The provider-assigned unique ID for this managed resource.

iterationId String
labels Map<Any>
organizationId String
packerRunUuid String
projectId String
region String
revokeAt String
channel String

Package Details

Repository
https://github.com/grapl-security/pulumi-hcp
License
Apache-2.0
Notes

This Pulumi package is based on the hcp Terraform Provider.