1. Packages
  2. HCP
  3. API Docs
  4. getPackerImage
HashiCorp Cloud Platform (HCP) v0.1.14 published on Friday, Dec 2, 2022 by Grapl Security

hcp.getPackerImage

Explore with Pulumi AI

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 System.Collections.Generic;
using Pulumi;
using Hcp = Pulumi.Hcp;

return await Deployment.RunAsync(() => 
{
    var baz = Hcp.GetPackerImage.Invoke(new()
    {
        BucketName = "hardened-ubuntu-16-04",
        CloudProvider = "aws",
        Channel = "production",
        Region = "us-east-1",
    });

    return new Dictionary<string, object?>
    {
        ["packer-registry-ubuntu-east-1"] = baz.Apply(getPackerImageResult => getPackerImageResult.CloudImageId),
    };
});
Copy
package main

import (
	"github.com/grapl-security/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
	})
}
Copy
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()));
    }
}
Copy
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,
    };
}
Copy
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)
Copy
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}
Copy

Multiple image sourcing from a single iteration

using System.Collections.Generic;
using Pulumi;
using Hcp = Pulumi.Hcp;

return await Deployment.RunAsync(() => 
{
    var hardened_source = Hcp.GetPackerIteration.Invoke(new()
    {
        BucketName = "hardened-ubuntu-16-04",
        Channel = "production",
    });

    var foo = Hcp.GetPackerImage.Invoke(new()
    {
        BucketName = "hardened-ubuntu-16-04",
        CloudProvider = "aws",
        IterationId = hardened_source.Apply(getPackerIterationResult => getPackerIterationResult.Ulid),
        Region = "us-east-1",
    });

    var bar = Hcp.GetPackerImage.Invoke(new()
    {
        BucketName = "hardened-ubuntu-16-04",
        CloudProvider = "aws",
        IterationId = hardened_source.Apply(getPackerIterationResult => getPackerIterationResult.Ulid),
        Region = "us-west-1",
    });

    return new Dictionary<string, object?>
    {
        ["packer-registry-ubuntu-east-1"] = foo.Apply(getPackerImageResult => getPackerImageResult.CloudImageId),
        ["packer-registry-ubuntu-west-1"] = bar.Apply(getPackerImageResult => getPackerImageResult.CloudImageId),
    };
});
Copy
package main

import (
	"github.com/grapl-security/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
	})
}
Copy
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()));
    }
}
Copy
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,
    };
}
Copy
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)
Copy
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}
Copy

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>
Copy
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]
Copy
func GetPackerImage(ctx *Context, args *GetPackerImageArgs, opts ...InvokeOption) (*GetPackerImageResult, error)
func GetPackerImageOutput(ctx *Context, args *GetPackerImageOutputArgs, opts ...InvokeOption) GetPackerImageResultOutput
Copy

> 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)
}
Copy
public static CompletableFuture<GetPackerImageResult> getPackerImage(GetPackerImageArgs args, InvokeOptions options)
public static Output<GetPackerImageResult> getPackerImage(GetPackerImageArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: hcp:index/getPackerImage:getPackerImage
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

BucketName This property is required. string
The slug of the HCP Packer Registry image bucket to pull from.
CloudProvider This property is required. string
Name of the cloud provider this image is stored-in.
Region This property is required. string
Region this image is stored in, if any.
Channel string
The channel that points to the version of the image being retrieved. Either this or iteration_id must be specified. Note: will incur a billable request
ComponentType string
Name of the builder that built this image. Ex: amazon-ebs.example.
IterationId string
The iteration from which to get the image. Either this or channel must be specified.
BucketName This property is required. string
The slug of the HCP Packer Registry image bucket to pull from.
CloudProvider This property is required. string
Name of the cloud provider this image is stored-in.
Region This property is required. string
Region this image is stored in, if any.
Channel string
The channel that points to the version of the image being retrieved. Either this or iteration_id must be specified. Note: will incur a billable request
ComponentType string
Name of the builder that built this image. Ex: amazon-ebs.example.
IterationId string
The iteration from which to get the image. Either this or channel must be specified.
bucketName This property is required. String
The slug of the HCP Packer Registry image bucket to pull from.
cloudProvider This property is required. String
Name of the cloud provider this image is stored-in.
region This property is required. String
Region this image is stored in, if any.
channel String
The channel that points to the version of the image being retrieved. Either this or iteration_id must be specified. Note: will incur a billable request
componentType String
Name of the builder that built this image. Ex: amazon-ebs.example.
iterationId String
The iteration from which to get the image. Either this or channel must be specified.
bucketName This property is required. string
The slug of the HCP Packer Registry image bucket to pull from.
cloudProvider This property is required. string
Name of the cloud provider this image is stored-in.
region This property is required. string
Region this image is stored in, if any.
channel string
The channel that points to the version of the image being retrieved. Either this or iteration_id must be specified. Note: will incur a billable request
componentType string
Name of the builder that built this image. Ex: amazon-ebs.example.
iterationId string
The iteration from which to get the image. Either this or channel must be specified.
bucket_name This property is required. str
The slug of the HCP Packer Registry image bucket to pull from.
cloud_provider This property is required. str
Name of the cloud provider this image is stored-in.
region This property is required. str
Region this image is stored in, if any.
channel str
The channel that points to the version of the image being retrieved. Either this or iteration_id must be specified. Note: will incur a billable request
component_type str
Name of the builder that built this image. Ex: amazon-ebs.example.
iteration_id str
The iteration from which to get the image. Either this or channel must be specified.
bucketName This property is required. String
The slug of the HCP Packer Registry image bucket to pull from.
cloudProvider This property is required. String
Name of the cloud provider this image is stored-in.
region This property is required. String
Region this image is stored in, if any.
channel String
The channel that points to the version of the image being retrieved. Either this or iteration_id must be specified. Note: will incur a billable request
componentType String
Name of the builder that built this image. Ex: amazon-ebs.example.
iterationId String
The iteration from which to get the image. Either this or channel must be specified.

getPackerImage Result

The following output properties are available:

BucketName string
The slug of the HCP Packer Registry image bucket to pull from.
BuildId string
HCP ID of this build.
CloudImageId string
Cloud Image ID or URL string identifying this image for the builder that built it.
CloudProvider string
Name of the cloud provider this image is stored-in.
ComponentType string
Name of the builder that built this image. Ex: amazon-ebs.example.
CreatedAt string
Creation time of this build.
Id string
The provider-assigned unique ID for this managed resource.
IterationId string
The iteration from which to get the image. Either this or channel must be specified.
Labels Dictionary<string, object>
Labels associated with this build.
OrganizationId string
The ID of the organization this HCP Packer registry is located in.
PackerRunUuid string
UUID of this build.
ProjectId string
The ID of the project this HCP Packer registry is located in.
Region string
Region this image is stored in, if any.
RevokeAt string
The revocation time of this build. This field will be null for any build that has not been revoked or scheduled for revocation.
Channel string
The channel that points to the version of the image being retrieved. Either this or iteration_id must be specified. Note: will incur a billable request
BucketName string
The slug of the HCP Packer Registry image bucket to pull from.
BuildId string
HCP ID of this build.
CloudImageId string
Cloud Image ID or URL string identifying this image for the builder that built it.
CloudProvider string
Name of the cloud provider this image is stored-in.
ComponentType string
Name of the builder that built this image. Ex: amazon-ebs.example.
CreatedAt string
Creation time of this build.
Id string
The provider-assigned unique ID for this managed resource.
IterationId string
The iteration from which to get the image. Either this or channel must be specified.
Labels map[string]interface{}
Labels associated with this build.
OrganizationId string
The ID of the organization this HCP Packer registry is located in.
PackerRunUuid string
UUID of this build.
ProjectId string
The ID of the project this HCP Packer registry is located in.
Region string
Region this image is stored in, if any.
RevokeAt string
The revocation time of this build. This field will be null for any build that has not been revoked or scheduled for revocation.
Channel string
The channel that points to the version of the image being retrieved. Either this or iteration_id must be specified. Note: will incur a billable request
bucketName String
The slug of the HCP Packer Registry image bucket to pull from.
buildId String
HCP ID of this build.
cloudImageId String
Cloud Image ID or URL string identifying this image for the builder that built it.
cloudProvider String
Name of the cloud provider this image is stored-in.
componentType String
Name of the builder that built this image. Ex: amazon-ebs.example.
createdAt String
Creation time of this build.
id String
The provider-assigned unique ID for this managed resource.
iterationId String
The iteration from which to get the image. Either this or channel must be specified.
labels Map<String,Object>
Labels associated with this build.
organizationId String
The ID of the organization this HCP Packer registry is located in.
packerRunUuid String
UUID of this build.
projectId String
The ID of the project this HCP Packer registry is located in.
region String
Region this image is stored in, if any.
revokeAt String
The revocation time of this build. This field will be null for any build that has not been revoked or scheduled for revocation.
channel String
The channel that points to the version of the image being retrieved. Either this or iteration_id must be specified. Note: will incur a billable request
bucketName string
The slug of the HCP Packer Registry image bucket to pull from.
buildId string
HCP ID of this build.
cloudImageId string
Cloud Image ID or URL string identifying this image for the builder that built it.
cloudProvider string
Name of the cloud provider this image is stored-in.
componentType string
Name of the builder that built this image. Ex: amazon-ebs.example.
createdAt string
Creation time of this build.
id string
The provider-assigned unique ID for this managed resource.
iterationId string
The iteration from which to get the image. Either this or channel must be specified.
labels {[key: string]: any}
Labels associated with this build.
organizationId string
The ID of the organization this HCP Packer registry is located in.
packerRunUuid string
UUID of this build.
projectId string
The ID of the project this HCP Packer registry is located in.
region string
Region this image is stored in, if any.
revokeAt string
The revocation time of this build. This field will be null for any build that has not been revoked or scheduled for revocation.
channel string
The channel that points to the version of the image being retrieved. Either this or iteration_id must be specified. Note: will incur a billable request
bucket_name str
The slug of the HCP Packer Registry image bucket to pull from.
build_id str
HCP ID of this build.
cloud_image_id str
Cloud Image ID or URL string identifying this image for the builder that built it.
cloud_provider str
Name of the cloud provider this image is stored-in.
component_type str
Name of the builder that built this image. Ex: amazon-ebs.example.
created_at str
Creation time of this build.
id str
The provider-assigned unique ID for this managed resource.
iteration_id str
The iteration from which to get the image. Either this or channel must be specified.
labels Mapping[str, Any]
Labels associated with this build.
organization_id str
The ID of the organization this HCP Packer registry is located in.
packer_run_uuid str
UUID of this build.
project_id str
The ID of the project this HCP Packer registry is located in.
region str
Region this image is stored in, if any.
revoke_at str
The revocation time of this build. This field will be null for any build that has not been revoked or scheduled for revocation.
channel str
The channel that points to the version of the image being retrieved. Either this or iteration_id must be specified. Note: will incur a billable request
bucketName String
The slug of the HCP Packer Registry image bucket to pull from.
buildId String
HCP ID of this build.
cloudImageId String
Cloud Image ID or URL string identifying this image for the builder that built it.
cloudProvider String
Name of the cloud provider this image is stored-in.
componentType String
Name of the builder that built this image. Ex: amazon-ebs.example.
createdAt String
Creation time of this build.
id String
The provider-assigned unique ID for this managed resource.
iterationId String
The iteration from which to get the image. Either this or channel must be specified.
labels Map<Any>
Labels associated with this build.
organizationId String
The ID of the organization this HCP Packer registry is located in.
packerRunUuid String
UUID of this build.
projectId String
The ID of the project this HCP Packer registry is located in.
region String
Region this image is stored in, if any.
revokeAt String
The revocation time of this build. This field will be null for any build that has not been revoked or scheduled for revocation.
channel String
The channel that points to the version of the image being retrieved. Either this or iteration_id must be specified. Note: will incur a billable request

Package Details

Repository
hcp grapl-security/pulumi-hcp
License
Apache-2.0
Notes
This Pulumi package is based on the hcp Terraform Provider.