github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/cloudhsmv2/hsm.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package cloudhsmv2
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Creates an HSM module in Amazon CloudHSM v2 cluster.
    16  //
    17  // ## Example Usage
    18  //
    19  // The following example below creates an HSM module in CloudHSM cluster.
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudhsmv2"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			cluster, err := cloudhsmv2.LookupCluster(ctx, &cloudhsmv2.LookupClusterArgs{
    35  //				ClusterId: cloudhsmClusterId,
    36  //			}, nil)
    37  //			if err != nil {
    38  //				return err
    39  //			}
    40  //			_, err = cloudhsmv2.NewHsm(ctx, "cloudhsm_v2_hsm", &cloudhsmv2.HsmArgs{
    41  //				SubnetId:  pulumi.String(cluster.SubnetIds[0]),
    42  //				ClusterId: pulumi.String(cluster.ClusterId),
    43  //			})
    44  //			if err != nil {
    45  //				return err
    46  //			}
    47  //			return nil
    48  //		})
    49  //	}
    50  //
    51  // ```
    52  // <!--End PulumiCodeChooser -->
    53  //
    54  // ## Import
    55  //
    56  // Using `pulumi import`, import HSM modules using their HSM ID. For example:
    57  //
    58  // ```sh
    59  // $ pulumi import aws:cloudhsmv2/hsm:Hsm bar hsm-quo8dahtaca
    60  // ```
    61  type Hsm struct {
    62  	pulumi.CustomResourceState
    63  
    64  	// The IDs of AZ in which HSM module will be located. Conflicts with `subnetId`.
    65  	AvailabilityZone pulumi.StringOutput `pulumi:"availabilityZone"`
    66  	// The ID of Cloud HSM v2 cluster to which HSM will be added.
    67  	ClusterId pulumi.StringOutput `pulumi:"clusterId"`
    68  	// The id of the ENI interface allocated for HSM module.
    69  	HsmEniId pulumi.StringOutput `pulumi:"hsmEniId"`
    70  	// The id of the HSM module.
    71  	HsmId pulumi.StringOutput `pulumi:"hsmId"`
    72  	// The state of the HSM module.
    73  	HsmState pulumi.StringOutput `pulumi:"hsmState"`
    74  	// The IP address of HSM module. Must be within the CIDR of selected subnet.
    75  	IpAddress pulumi.StringOutput `pulumi:"ipAddress"`
    76  	// The ID of subnet in which HSM module will be located. Conflicts with `availabilityZone`.
    77  	SubnetId pulumi.StringOutput `pulumi:"subnetId"`
    78  }
    79  
    80  // NewHsm registers a new resource with the given unique name, arguments, and options.
    81  func NewHsm(ctx *pulumi.Context,
    82  	name string, args *HsmArgs, opts ...pulumi.ResourceOption) (*Hsm, error) {
    83  	if args == nil {
    84  		return nil, errors.New("missing one or more required arguments")
    85  	}
    86  
    87  	if args.ClusterId == nil {
    88  		return nil, errors.New("invalid value for required argument 'ClusterId'")
    89  	}
    90  	opts = internal.PkgResourceDefaultOpts(opts)
    91  	var resource Hsm
    92  	err := ctx.RegisterResource("aws:cloudhsmv2/hsm:Hsm", name, args, &resource, opts...)
    93  	if err != nil {
    94  		return nil, err
    95  	}
    96  	return &resource, nil
    97  }
    98  
    99  // GetHsm gets an existing Hsm resource's state with the given name, ID, and optional
   100  // state properties that are used to uniquely qualify the lookup (nil if not required).
   101  func GetHsm(ctx *pulumi.Context,
   102  	name string, id pulumi.IDInput, state *HsmState, opts ...pulumi.ResourceOption) (*Hsm, error) {
   103  	var resource Hsm
   104  	err := ctx.ReadResource("aws:cloudhsmv2/hsm:Hsm", name, id, state, &resource, opts...)
   105  	if err != nil {
   106  		return nil, err
   107  	}
   108  	return &resource, nil
   109  }
   110  
   111  // Input properties used for looking up and filtering Hsm resources.
   112  type hsmState struct {
   113  	// The IDs of AZ in which HSM module will be located. Conflicts with `subnetId`.
   114  	AvailabilityZone *string `pulumi:"availabilityZone"`
   115  	// The ID of Cloud HSM v2 cluster to which HSM will be added.
   116  	ClusterId *string `pulumi:"clusterId"`
   117  	// The id of the ENI interface allocated for HSM module.
   118  	HsmEniId *string `pulumi:"hsmEniId"`
   119  	// The id of the HSM module.
   120  	HsmId *string `pulumi:"hsmId"`
   121  	// The state of the HSM module.
   122  	HsmState *string `pulumi:"hsmState"`
   123  	// The IP address of HSM module. Must be within the CIDR of selected subnet.
   124  	IpAddress *string `pulumi:"ipAddress"`
   125  	// The ID of subnet in which HSM module will be located. Conflicts with `availabilityZone`.
   126  	SubnetId *string `pulumi:"subnetId"`
   127  }
   128  
   129  type HsmState struct {
   130  	// The IDs of AZ in which HSM module will be located. Conflicts with `subnetId`.
   131  	AvailabilityZone pulumi.StringPtrInput
   132  	// The ID of Cloud HSM v2 cluster to which HSM will be added.
   133  	ClusterId pulumi.StringPtrInput
   134  	// The id of the ENI interface allocated for HSM module.
   135  	HsmEniId pulumi.StringPtrInput
   136  	// The id of the HSM module.
   137  	HsmId pulumi.StringPtrInput
   138  	// The state of the HSM module.
   139  	HsmState pulumi.StringPtrInput
   140  	// The IP address of HSM module. Must be within the CIDR of selected subnet.
   141  	IpAddress pulumi.StringPtrInput
   142  	// The ID of subnet in which HSM module will be located. Conflicts with `availabilityZone`.
   143  	SubnetId pulumi.StringPtrInput
   144  }
   145  
   146  func (HsmState) ElementType() reflect.Type {
   147  	return reflect.TypeOf((*hsmState)(nil)).Elem()
   148  }
   149  
   150  type hsmArgs struct {
   151  	// The IDs of AZ in which HSM module will be located. Conflicts with `subnetId`.
   152  	AvailabilityZone *string `pulumi:"availabilityZone"`
   153  	// The ID of Cloud HSM v2 cluster to which HSM will be added.
   154  	ClusterId string `pulumi:"clusterId"`
   155  	// The IP address of HSM module. Must be within the CIDR of selected subnet.
   156  	IpAddress *string `pulumi:"ipAddress"`
   157  	// The ID of subnet in which HSM module will be located. Conflicts with `availabilityZone`.
   158  	SubnetId *string `pulumi:"subnetId"`
   159  }
   160  
   161  // The set of arguments for constructing a Hsm resource.
   162  type HsmArgs struct {
   163  	// The IDs of AZ in which HSM module will be located. Conflicts with `subnetId`.
   164  	AvailabilityZone pulumi.StringPtrInput
   165  	// The ID of Cloud HSM v2 cluster to which HSM will be added.
   166  	ClusterId pulumi.StringInput
   167  	// The IP address of HSM module. Must be within the CIDR of selected subnet.
   168  	IpAddress pulumi.StringPtrInput
   169  	// The ID of subnet in which HSM module will be located. Conflicts with `availabilityZone`.
   170  	SubnetId pulumi.StringPtrInput
   171  }
   172  
   173  func (HsmArgs) ElementType() reflect.Type {
   174  	return reflect.TypeOf((*hsmArgs)(nil)).Elem()
   175  }
   176  
   177  type HsmInput interface {
   178  	pulumi.Input
   179  
   180  	ToHsmOutput() HsmOutput
   181  	ToHsmOutputWithContext(ctx context.Context) HsmOutput
   182  }
   183  
   184  func (*Hsm) ElementType() reflect.Type {
   185  	return reflect.TypeOf((**Hsm)(nil)).Elem()
   186  }
   187  
   188  func (i *Hsm) ToHsmOutput() HsmOutput {
   189  	return i.ToHsmOutputWithContext(context.Background())
   190  }
   191  
   192  func (i *Hsm) ToHsmOutputWithContext(ctx context.Context) HsmOutput {
   193  	return pulumi.ToOutputWithContext(ctx, i).(HsmOutput)
   194  }
   195  
   196  // HsmArrayInput is an input type that accepts HsmArray and HsmArrayOutput values.
   197  // You can construct a concrete instance of `HsmArrayInput` via:
   198  //
   199  //	HsmArray{ HsmArgs{...} }
   200  type HsmArrayInput interface {
   201  	pulumi.Input
   202  
   203  	ToHsmArrayOutput() HsmArrayOutput
   204  	ToHsmArrayOutputWithContext(context.Context) HsmArrayOutput
   205  }
   206  
   207  type HsmArray []HsmInput
   208  
   209  func (HsmArray) ElementType() reflect.Type {
   210  	return reflect.TypeOf((*[]*Hsm)(nil)).Elem()
   211  }
   212  
   213  func (i HsmArray) ToHsmArrayOutput() HsmArrayOutput {
   214  	return i.ToHsmArrayOutputWithContext(context.Background())
   215  }
   216  
   217  func (i HsmArray) ToHsmArrayOutputWithContext(ctx context.Context) HsmArrayOutput {
   218  	return pulumi.ToOutputWithContext(ctx, i).(HsmArrayOutput)
   219  }
   220  
   221  // HsmMapInput is an input type that accepts HsmMap and HsmMapOutput values.
   222  // You can construct a concrete instance of `HsmMapInput` via:
   223  //
   224  //	HsmMap{ "key": HsmArgs{...} }
   225  type HsmMapInput interface {
   226  	pulumi.Input
   227  
   228  	ToHsmMapOutput() HsmMapOutput
   229  	ToHsmMapOutputWithContext(context.Context) HsmMapOutput
   230  }
   231  
   232  type HsmMap map[string]HsmInput
   233  
   234  func (HsmMap) ElementType() reflect.Type {
   235  	return reflect.TypeOf((*map[string]*Hsm)(nil)).Elem()
   236  }
   237  
   238  func (i HsmMap) ToHsmMapOutput() HsmMapOutput {
   239  	return i.ToHsmMapOutputWithContext(context.Background())
   240  }
   241  
   242  func (i HsmMap) ToHsmMapOutputWithContext(ctx context.Context) HsmMapOutput {
   243  	return pulumi.ToOutputWithContext(ctx, i).(HsmMapOutput)
   244  }
   245  
   246  type HsmOutput struct{ *pulumi.OutputState }
   247  
   248  func (HsmOutput) ElementType() reflect.Type {
   249  	return reflect.TypeOf((**Hsm)(nil)).Elem()
   250  }
   251  
   252  func (o HsmOutput) ToHsmOutput() HsmOutput {
   253  	return o
   254  }
   255  
   256  func (o HsmOutput) ToHsmOutputWithContext(ctx context.Context) HsmOutput {
   257  	return o
   258  }
   259  
   260  // The IDs of AZ in which HSM module will be located. Conflicts with `subnetId`.
   261  func (o HsmOutput) AvailabilityZone() pulumi.StringOutput {
   262  	return o.ApplyT(func(v *Hsm) pulumi.StringOutput { return v.AvailabilityZone }).(pulumi.StringOutput)
   263  }
   264  
   265  // The ID of Cloud HSM v2 cluster to which HSM will be added.
   266  func (o HsmOutput) ClusterId() pulumi.StringOutput {
   267  	return o.ApplyT(func(v *Hsm) pulumi.StringOutput { return v.ClusterId }).(pulumi.StringOutput)
   268  }
   269  
   270  // The id of the ENI interface allocated for HSM module.
   271  func (o HsmOutput) HsmEniId() pulumi.StringOutput {
   272  	return o.ApplyT(func(v *Hsm) pulumi.StringOutput { return v.HsmEniId }).(pulumi.StringOutput)
   273  }
   274  
   275  // The id of the HSM module.
   276  func (o HsmOutput) HsmId() pulumi.StringOutput {
   277  	return o.ApplyT(func(v *Hsm) pulumi.StringOutput { return v.HsmId }).(pulumi.StringOutput)
   278  }
   279  
   280  // The state of the HSM module.
   281  func (o HsmOutput) HsmState() pulumi.StringOutput {
   282  	return o.ApplyT(func(v *Hsm) pulumi.StringOutput { return v.HsmState }).(pulumi.StringOutput)
   283  }
   284  
   285  // The IP address of HSM module. Must be within the CIDR of selected subnet.
   286  func (o HsmOutput) IpAddress() pulumi.StringOutput {
   287  	return o.ApplyT(func(v *Hsm) pulumi.StringOutput { return v.IpAddress }).(pulumi.StringOutput)
   288  }
   289  
   290  // The ID of subnet in which HSM module will be located. Conflicts with `availabilityZone`.
   291  func (o HsmOutput) SubnetId() pulumi.StringOutput {
   292  	return o.ApplyT(func(v *Hsm) pulumi.StringOutput { return v.SubnetId }).(pulumi.StringOutput)
   293  }
   294  
   295  type HsmArrayOutput struct{ *pulumi.OutputState }
   296  
   297  func (HsmArrayOutput) ElementType() reflect.Type {
   298  	return reflect.TypeOf((*[]*Hsm)(nil)).Elem()
   299  }
   300  
   301  func (o HsmArrayOutput) ToHsmArrayOutput() HsmArrayOutput {
   302  	return o
   303  }
   304  
   305  func (o HsmArrayOutput) ToHsmArrayOutputWithContext(ctx context.Context) HsmArrayOutput {
   306  	return o
   307  }
   308  
   309  func (o HsmArrayOutput) Index(i pulumi.IntInput) HsmOutput {
   310  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Hsm {
   311  		return vs[0].([]*Hsm)[vs[1].(int)]
   312  	}).(HsmOutput)
   313  }
   314  
   315  type HsmMapOutput struct{ *pulumi.OutputState }
   316  
   317  func (HsmMapOutput) ElementType() reflect.Type {
   318  	return reflect.TypeOf((*map[string]*Hsm)(nil)).Elem()
   319  }
   320  
   321  func (o HsmMapOutput) ToHsmMapOutput() HsmMapOutput {
   322  	return o
   323  }
   324  
   325  func (o HsmMapOutput) ToHsmMapOutputWithContext(ctx context.Context) HsmMapOutput {
   326  	return o
   327  }
   328  
   329  func (o HsmMapOutput) MapIndex(k pulumi.StringInput) HsmOutput {
   330  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Hsm {
   331  		return vs[0].(map[string]*Hsm)[vs[1].(string)]
   332  	}).(HsmOutput)
   333  }
   334  
   335  func init() {
   336  	pulumi.RegisterInputType(reflect.TypeOf((*HsmInput)(nil)).Elem(), &Hsm{})
   337  	pulumi.RegisterInputType(reflect.TypeOf((*HsmArrayInput)(nil)).Elem(), HsmArray{})
   338  	pulumi.RegisterInputType(reflect.TypeOf((*HsmMapInput)(nil)).Elem(), HsmMap{})
   339  	pulumi.RegisterOutputType(HsmOutput{})
   340  	pulumi.RegisterOutputType(HsmArrayOutput{})
   341  	pulumi.RegisterOutputType(HsmMapOutput{})
   342  }