Cluster class

Creates an Amazon CloudHSM v2 cluster.

For information about CloudHSM v2, see the AWS CloudHSM User Guide and the Amazon CloudHSM API Reference.

> NOTE: A CloudHSM Cluster can take several minutes to set up. Practically no single attribute can be updated, except for tags. If you need to delete a cluster, you have to remove its HSM modules first. To initialize cluster, you have to add an HSM instance to the cluster, then sign CSR and upload it.

Example Usage

The following example below creates a CloudHSM cluster.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const available = aws.getAvailabilityZones({});
const cloudhsmV2Vpc = new aws.ec2.Vpc("cloudhsm_v2_vpc", {
    cidrBlock: "10.0.0.0/16",
    tags: {
        Name: "example-aws_cloudhsm_v2_cluster",
    },
});
const cloudhsmV2Subnets: aws.ec2.Subnet[] = [];
for (let range = 0; range < 2; range++) {
    cloudhsmV2Subnets.push(new aws.ec2.Subnet(`cloudhsm_v2_subnets-${range}`, {
        vpcId: cloudhsmV2Vpc.id,
        cidrBlock: subnets[range],
        mapPublicIpOnLaunch: false,
        availabilityZone: available.then(available => available.names)[range],
        tags: {
            Name: "example-aws_cloudhsm_v2_cluster",
        },
    }));
}
const cloudhsmV2Cluster = new aws.cloudhsmv2.Cluster("cloudhsm_v2_cluster", {
    hsmType: "hsm1.medium",
    subnetIds: cloudhsmV2Subnets.map(__item => __item.id),
    tags: {
        Name: "example-aws_cloudhsm_v2_cluster",
    },
});
import pulumi
from typing import Any
import pulumi_aws as aws

available = aws.get_availability_zones()
cloudhsm_v2_vpc = aws.ec2.Vpc("cloudhsm_v2_vpc",
    cidr_block="10.0.0.0/16",
    tags={
        "Name": "example-aws_cloudhsm_v2_cluster",
    })
cloudhsm_v2_subnets: list[aws.ec2.Subnet] = []
for cloudhsm_v2_subnets_range in [{"value": i} for i in range(0, 2)]:
    cloudhsm_v2_subnets.append(aws.ec2.Subnet(f"cloudhsm_v2_subnets-{cloudhsm_v2_subnets_range['value']}",
        vpc_id=cloudhsm_v2_vpc.id,
        cidr_block=subnets[cloudhsm_v2_subnets_range["value"]],
        map_public_ip_on_launch=False,
        availability_zone=available.names[cloudhsm_v2_subnets_range["value"]],
        tags={
            "Name": "example-aws_cloudhsm_v2_cluster",
        }))
cloudhsm_v2_cluster = aws.cloudhsmv2.Cluster("cloudhsm_v2_cluster",
    hsm_type="hsm1.medium",
    subnet_ids=[__item.id for __item in cloudhsm_v2_subnets],
    tags={
        "Name": "example-aws_cloudhsm_v2_cluster",
    })
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var available = Aws.GetAvailabilityZones.Invoke();

    var cloudhsmV2Vpc = new Aws.Ec2.Vpc("cloudhsm_v2_vpc", new()
    {
        CidrBlock = "10.0.0.0/16",
        Tags =
        {
            { "Name", "example-aws_cloudhsm_v2_cluster" },
        },
    });

    var cloudhsmV2Subnets = new List<Aws.Ec2.Subnet>();
    for (var rangeIndex = 0; rangeIndex < 2; rangeIndex++)
    {
        var range = new { Value = rangeIndex };
        cloudhsmV2Subnets.Add(new Aws.Ec2.Subnet($"cloudhsm_v2_subnets-{range.Value}", new()
        {
            VpcId = cloudhsmV2Vpc.Id,
            CidrBlock = subnets[range.Value],
            MapPublicIpOnLaunch = false,
            AvailabilityZone = available.Apply(getAvailabilityZonesResult => getAvailabilityZonesResult.Names)[range.Value],
            Tags =
            {
                { "Name", "example-aws_cloudhsm_v2_cluster" },
            },
        }));
    }
    var cloudhsmV2Cluster = new Aws.CloudHsmV2.Cluster("cloudhsm_v2_cluster", new()
    {
        HsmType = "hsm1.medium",
        SubnetIds = cloudhsmV2Subnets.Select(__item => __item.Id).ToList(),
        Tags =
        {
            { "Name", "example-aws_cloudhsm_v2_cluster" },
        },
    });

});
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/cloudhsmv2"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ec2"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		available, err := aws.GetAvailabilityZones(ctx, &aws.GetAvailabilityZonesArgs{}, nil)
		if err != nil {
			return err
		}
		cloudhsmV2Vpc, err := ec2.NewVpc(ctx, "cloudhsm_v2_vpc", &ec2.VpcArgs{
			CidrBlock: pulumi.String("10.0.0.0/16"),
			Tags: pulumi.StringMap{
				"Name": pulumi.String("example-aws_cloudhsm_v2_cluster"),
			},
		})
		if err != nil {
			return err
		}
		var cloudhsmV2Subnets []*ec2.Subnet
		for index := 0; index < 2; index++ {
			key0 := index
			val0 := index
			__res, err := ec2.NewSubnet(ctx, fmt.Sprintf("cloudhsm_v2_subnets-%v", key0), &ec2.SubnetArgs{
				VpcId:               cloudhsmV2Vpc.ID().ToIDOutput().ToStringOutput(),
				CidrBlock:           subnets[val0],
				MapPublicIpOnLaunch: pulumi.Bool(false),
				AvailabilityZone:    available.Names[val0],
				Tags: pulumi.StringMap{
					"Name": pulumi.String("example-aws_cloudhsm_v2_cluster"),
				},
			})
			if err != nil {
				return err
			}
			cloudhsmV2Subnets = append(cloudhsmV2Subnets, __res)
		}
		var splat0 pulumi.IDArray
		for _, val0 := range cloudhsmV2Subnets {
			splat0 = append(splat0, val0.ID())
		}
		_, err = cloudhsmv2.NewCluster(ctx, "cloudhsm_v2_cluster", &cloudhsmv2.ClusterArgs{
			HsmType:   pulumi.String("hsm1.medium"),
			SubnetIds: toPulumiIDArray(splat0),
			Tags: pulumi.StringMap{
				"Name": pulumi.String("example-aws_cloudhsm_v2_cluster"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
func toPulumiIDArray(arr []pulumi.ID) pulumi.IDArray {
	var pulumiArr pulumi.IDArray
	for _, v := range arr {
		pulumiArr = append(pulumiArr, pulumi.ID(v))
	}
	return pulumiArr
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_getavailabilityzones" "available" {
}

resource "aws_ec2_vpc" "cloudhsm_v2_vpc" {
  cidr_block = "10.0.0.0/16"
  tags = {
    "Name" = "example-aws_cloudhsm_v2_cluster"
  }
}
resource "aws_ec2_subnet" "cloudhsm_v2_subnets" {
  count                   = 2
  vpc_id                  = aws_ec2_vpc.cloudhsm_v2_vpc.id
  cidr_block              = element(subnets, count.index)
  map_public_ip_on_launch = false
  availability_zone       = element(data.aws_getavailabilityzones.available.names, count.index)
  tags = {
    "Name" = "example-aws_cloudhsm_v2_cluster"
  }
}
resource "aws_cloudhsmv2_cluster" "cloudhsm_v2_cluster" {
  hsm_type   = "hsm1.medium"
  subnet_ids = aws_ec2_subnet.cloudhsm_v2_subnets[*].id
  tags = {
    "Name" = "example-aws_cloudhsm_v2_cluster"
  }
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.AwsFunctions;
import com.pulumi.aws.inputs.GetAvailabilityZonesArgs;
import com.pulumi.aws.ec2.Vpc;
import com.pulumi.aws.ec2.VpcArgs;
import com.pulumi.aws.ec2.Subnet;
import com.pulumi.aws.ec2.SubnetArgs;
import com.pulumi.aws.cloudhsmv2.Cluster;
import com.pulumi.aws.cloudhsmv2.ClusterArgs;
import com.pulumi.codegen.internal.KeyedValue;
import java.util.ArrayList;
import java.util.Arrays;
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 available = AwsFunctions.getAvailabilityZones(GetAvailabilityZonesArgs.builder()
            .build());

        var cloudhsmV2Vpc = new Vpc("cloudhsmV2Vpc", VpcArgs.builder()
            .cidrBlock("10.0.0.0/16")
            .tags(Map.of("Name", "example-aws_cloudhsm_v2_cluster"))
            .build());

        for (var i = 0; i < 2; i++) {
            new Subnet("cloudhsmV2Subnets-" + i, SubnetArgs.builder()
                .vpcId(cloudhsmV2Vpc.id())
                .cidrBlock(subnets[range.value()])
                .mapPublicIpOnLaunch(false)
                .availabilityZone(available.names()[range.value()])
                .tags(Map.of("Name", "example-aws_cloudhsm_v2_cluster"))
                .build());


}
        var cloudhsmV2Cluster = new Cluster("cloudhsmV2Cluster", ClusterArgs.builder()
            .hsmType("hsm1.medium")
            .subnetIds(cloudhsmV2Subnets.stream().map(element -> element.id()).collect(toList()))
            .tags(Map.of("Name", "example-aws_cloudhsm_v2_cluster"))
            .build());

    }
}

Import

Using pulumi import, import CloudHSM v2 Clusters using the cluster id. For example:

$ pulumi import aws:cloudhsmv2/cluster:Cluster test_cluster cluster-aeb282a201

Constructors

Cluster(String name, {ClusterArgs? args, CustomResourceOptions? options})
Creates a new Cluster. name The Pulumi resource name. args Arguments used to configure this Cluster. The set of arguments for Cluster. options Resource options controlling this resource's behavior.
Cluster.reference(String urn)
Creates a typed reference to an existing Cluster resource.

Properties

childResources → Set<Resource>
finalinherited
clusterCertificates ↔ Output<List<ClusterClusterCertificate>>
The list of cluster certificates.
latefinal
clusterId ↔ Output<String>
The id of the CloudHSM cluster.
latefinal
clusterState ↔ Output<String>
The state of the CloudHSM cluster.
latefinal
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
hashCode → int
The hash code for this object.
no setterinherited
hsmType ↔ Output<String>
The type of HSM module in the cluster. Currently, hsm1.medium and hsm2m.medium are supported.
latefinal
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
mode ↔ Output<String>
The mode to use in the cluster. The allowed values are FIPS and NON_FIPS. This field is required if hsmType is hsm2m.medium.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
securityGroupId ↔ Output<String>
The ID of the security group associated with the CloudHSM cluster.
latefinal
sourceBackupIdentifier ↔ Output<String?>
ID of Cloud HSM v2 cluster backup to be restored.
latefinal
subnetIds ↔ Output<List<String>>
The IDs of subnets in which cluster will operate.
latefinal
tags ↔ Output<Map<String, String>?>
A map of tags to assign to the resource. .If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
latefinal
tagsAll ↔ Output<Map<String, String>>
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited
vpcId ↔ Output<String>
The id of the VPC that the CloudHSM cluster resides in.
latefinal

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {ClusterState? state, CustomResourceOptions? options}) → Cluster
Gets an existing Cluster resource's state with the given name and id.