github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/lightsail/staticIpAttachment.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 lightsail
     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  // Provides a static IP address attachment - relationship between a Lightsail static IP & Lightsail instance.
    16  //
    17  // > **Note:** Lightsail is currently only supported in a limited number of AWS Regions, please see ["Regions and Availability Zones in Amazon Lightsail"](https://lightsail.aws.amazon.com/ls/docs/overview/article/understanding-regions-and-availability-zones-in-amazon-lightsail) for more details
    18  //
    19  // ## Example Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lightsail"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			testStaticIp, err := lightsail.NewStaticIp(ctx, "test", &lightsail.StaticIpArgs{
    35  //				Name: pulumi.String("example"),
    36  //			})
    37  //			if err != nil {
    38  //				return err
    39  //			}
    40  //			testInstance, err := lightsail.NewInstance(ctx, "test", &lightsail.InstanceArgs{
    41  //				Name:             pulumi.String("example"),
    42  //				AvailabilityZone: pulumi.String("us-east-1b"),
    43  //				BlueprintId:      pulumi.String("string"),
    44  //				BundleId:         pulumi.String("string"),
    45  //				KeyPairName:      pulumi.String("some_key_name"),
    46  //			})
    47  //			if err != nil {
    48  //				return err
    49  //			}
    50  //			_, err = lightsail.NewStaticIpAttachment(ctx, "test", &lightsail.StaticIpAttachmentArgs{
    51  //				StaticIpName: testStaticIp.ID(),
    52  //				InstanceName: testInstance.ID(),
    53  //			})
    54  //			if err != nil {
    55  //				return err
    56  //			}
    57  //			return nil
    58  //		})
    59  //	}
    60  //
    61  // ```
    62  // <!--End PulumiCodeChooser -->
    63  type StaticIpAttachment struct {
    64  	pulumi.CustomResourceState
    65  
    66  	// The name of the Lightsail instance to attach the IP to
    67  	InstanceName pulumi.StringOutput `pulumi:"instanceName"`
    68  	// The allocated static IP address
    69  	IpAddress pulumi.StringOutput `pulumi:"ipAddress"`
    70  	// The name of the allocated static IP
    71  	StaticIpName pulumi.StringOutput `pulumi:"staticIpName"`
    72  }
    73  
    74  // NewStaticIpAttachment registers a new resource with the given unique name, arguments, and options.
    75  func NewStaticIpAttachment(ctx *pulumi.Context,
    76  	name string, args *StaticIpAttachmentArgs, opts ...pulumi.ResourceOption) (*StaticIpAttachment, error) {
    77  	if args == nil {
    78  		return nil, errors.New("missing one or more required arguments")
    79  	}
    80  
    81  	if args.InstanceName == nil {
    82  		return nil, errors.New("invalid value for required argument 'InstanceName'")
    83  	}
    84  	if args.StaticIpName == nil {
    85  		return nil, errors.New("invalid value for required argument 'StaticIpName'")
    86  	}
    87  	opts = internal.PkgResourceDefaultOpts(opts)
    88  	var resource StaticIpAttachment
    89  	err := ctx.RegisterResource("aws:lightsail/staticIpAttachment:StaticIpAttachment", name, args, &resource, opts...)
    90  	if err != nil {
    91  		return nil, err
    92  	}
    93  	return &resource, nil
    94  }
    95  
    96  // GetStaticIpAttachment gets an existing StaticIpAttachment resource's state with the given name, ID, and optional
    97  // state properties that are used to uniquely qualify the lookup (nil if not required).
    98  func GetStaticIpAttachment(ctx *pulumi.Context,
    99  	name string, id pulumi.IDInput, state *StaticIpAttachmentState, opts ...pulumi.ResourceOption) (*StaticIpAttachment, error) {
   100  	var resource StaticIpAttachment
   101  	err := ctx.ReadResource("aws:lightsail/staticIpAttachment:StaticIpAttachment", name, id, state, &resource, opts...)
   102  	if err != nil {
   103  		return nil, err
   104  	}
   105  	return &resource, nil
   106  }
   107  
   108  // Input properties used for looking up and filtering StaticIpAttachment resources.
   109  type staticIpAttachmentState struct {
   110  	// The name of the Lightsail instance to attach the IP to
   111  	InstanceName *string `pulumi:"instanceName"`
   112  	// The allocated static IP address
   113  	IpAddress *string `pulumi:"ipAddress"`
   114  	// The name of the allocated static IP
   115  	StaticIpName *string `pulumi:"staticIpName"`
   116  }
   117  
   118  type StaticIpAttachmentState struct {
   119  	// The name of the Lightsail instance to attach the IP to
   120  	InstanceName pulumi.StringPtrInput
   121  	// The allocated static IP address
   122  	IpAddress pulumi.StringPtrInput
   123  	// The name of the allocated static IP
   124  	StaticIpName pulumi.StringPtrInput
   125  }
   126  
   127  func (StaticIpAttachmentState) ElementType() reflect.Type {
   128  	return reflect.TypeOf((*staticIpAttachmentState)(nil)).Elem()
   129  }
   130  
   131  type staticIpAttachmentArgs struct {
   132  	// The name of the Lightsail instance to attach the IP to
   133  	InstanceName string `pulumi:"instanceName"`
   134  	// The name of the allocated static IP
   135  	StaticIpName string `pulumi:"staticIpName"`
   136  }
   137  
   138  // The set of arguments for constructing a StaticIpAttachment resource.
   139  type StaticIpAttachmentArgs struct {
   140  	// The name of the Lightsail instance to attach the IP to
   141  	InstanceName pulumi.StringInput
   142  	// The name of the allocated static IP
   143  	StaticIpName pulumi.StringInput
   144  }
   145  
   146  func (StaticIpAttachmentArgs) ElementType() reflect.Type {
   147  	return reflect.TypeOf((*staticIpAttachmentArgs)(nil)).Elem()
   148  }
   149  
   150  type StaticIpAttachmentInput interface {
   151  	pulumi.Input
   152  
   153  	ToStaticIpAttachmentOutput() StaticIpAttachmentOutput
   154  	ToStaticIpAttachmentOutputWithContext(ctx context.Context) StaticIpAttachmentOutput
   155  }
   156  
   157  func (*StaticIpAttachment) ElementType() reflect.Type {
   158  	return reflect.TypeOf((**StaticIpAttachment)(nil)).Elem()
   159  }
   160  
   161  func (i *StaticIpAttachment) ToStaticIpAttachmentOutput() StaticIpAttachmentOutput {
   162  	return i.ToStaticIpAttachmentOutputWithContext(context.Background())
   163  }
   164  
   165  func (i *StaticIpAttachment) ToStaticIpAttachmentOutputWithContext(ctx context.Context) StaticIpAttachmentOutput {
   166  	return pulumi.ToOutputWithContext(ctx, i).(StaticIpAttachmentOutput)
   167  }
   168  
   169  // StaticIpAttachmentArrayInput is an input type that accepts StaticIpAttachmentArray and StaticIpAttachmentArrayOutput values.
   170  // You can construct a concrete instance of `StaticIpAttachmentArrayInput` via:
   171  //
   172  //	StaticIpAttachmentArray{ StaticIpAttachmentArgs{...} }
   173  type StaticIpAttachmentArrayInput interface {
   174  	pulumi.Input
   175  
   176  	ToStaticIpAttachmentArrayOutput() StaticIpAttachmentArrayOutput
   177  	ToStaticIpAttachmentArrayOutputWithContext(context.Context) StaticIpAttachmentArrayOutput
   178  }
   179  
   180  type StaticIpAttachmentArray []StaticIpAttachmentInput
   181  
   182  func (StaticIpAttachmentArray) ElementType() reflect.Type {
   183  	return reflect.TypeOf((*[]*StaticIpAttachment)(nil)).Elem()
   184  }
   185  
   186  func (i StaticIpAttachmentArray) ToStaticIpAttachmentArrayOutput() StaticIpAttachmentArrayOutput {
   187  	return i.ToStaticIpAttachmentArrayOutputWithContext(context.Background())
   188  }
   189  
   190  func (i StaticIpAttachmentArray) ToStaticIpAttachmentArrayOutputWithContext(ctx context.Context) StaticIpAttachmentArrayOutput {
   191  	return pulumi.ToOutputWithContext(ctx, i).(StaticIpAttachmentArrayOutput)
   192  }
   193  
   194  // StaticIpAttachmentMapInput is an input type that accepts StaticIpAttachmentMap and StaticIpAttachmentMapOutput values.
   195  // You can construct a concrete instance of `StaticIpAttachmentMapInput` via:
   196  //
   197  //	StaticIpAttachmentMap{ "key": StaticIpAttachmentArgs{...} }
   198  type StaticIpAttachmentMapInput interface {
   199  	pulumi.Input
   200  
   201  	ToStaticIpAttachmentMapOutput() StaticIpAttachmentMapOutput
   202  	ToStaticIpAttachmentMapOutputWithContext(context.Context) StaticIpAttachmentMapOutput
   203  }
   204  
   205  type StaticIpAttachmentMap map[string]StaticIpAttachmentInput
   206  
   207  func (StaticIpAttachmentMap) ElementType() reflect.Type {
   208  	return reflect.TypeOf((*map[string]*StaticIpAttachment)(nil)).Elem()
   209  }
   210  
   211  func (i StaticIpAttachmentMap) ToStaticIpAttachmentMapOutput() StaticIpAttachmentMapOutput {
   212  	return i.ToStaticIpAttachmentMapOutputWithContext(context.Background())
   213  }
   214  
   215  func (i StaticIpAttachmentMap) ToStaticIpAttachmentMapOutputWithContext(ctx context.Context) StaticIpAttachmentMapOutput {
   216  	return pulumi.ToOutputWithContext(ctx, i).(StaticIpAttachmentMapOutput)
   217  }
   218  
   219  type StaticIpAttachmentOutput struct{ *pulumi.OutputState }
   220  
   221  func (StaticIpAttachmentOutput) ElementType() reflect.Type {
   222  	return reflect.TypeOf((**StaticIpAttachment)(nil)).Elem()
   223  }
   224  
   225  func (o StaticIpAttachmentOutput) ToStaticIpAttachmentOutput() StaticIpAttachmentOutput {
   226  	return o
   227  }
   228  
   229  func (o StaticIpAttachmentOutput) ToStaticIpAttachmentOutputWithContext(ctx context.Context) StaticIpAttachmentOutput {
   230  	return o
   231  }
   232  
   233  // The name of the Lightsail instance to attach the IP to
   234  func (o StaticIpAttachmentOutput) InstanceName() pulumi.StringOutput {
   235  	return o.ApplyT(func(v *StaticIpAttachment) pulumi.StringOutput { return v.InstanceName }).(pulumi.StringOutput)
   236  }
   237  
   238  // The allocated static IP address
   239  func (o StaticIpAttachmentOutput) IpAddress() pulumi.StringOutput {
   240  	return o.ApplyT(func(v *StaticIpAttachment) pulumi.StringOutput { return v.IpAddress }).(pulumi.StringOutput)
   241  }
   242  
   243  // The name of the allocated static IP
   244  func (o StaticIpAttachmentOutput) StaticIpName() pulumi.StringOutput {
   245  	return o.ApplyT(func(v *StaticIpAttachment) pulumi.StringOutput { return v.StaticIpName }).(pulumi.StringOutput)
   246  }
   247  
   248  type StaticIpAttachmentArrayOutput struct{ *pulumi.OutputState }
   249  
   250  func (StaticIpAttachmentArrayOutput) ElementType() reflect.Type {
   251  	return reflect.TypeOf((*[]*StaticIpAttachment)(nil)).Elem()
   252  }
   253  
   254  func (o StaticIpAttachmentArrayOutput) ToStaticIpAttachmentArrayOutput() StaticIpAttachmentArrayOutput {
   255  	return o
   256  }
   257  
   258  func (o StaticIpAttachmentArrayOutput) ToStaticIpAttachmentArrayOutputWithContext(ctx context.Context) StaticIpAttachmentArrayOutput {
   259  	return o
   260  }
   261  
   262  func (o StaticIpAttachmentArrayOutput) Index(i pulumi.IntInput) StaticIpAttachmentOutput {
   263  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *StaticIpAttachment {
   264  		return vs[0].([]*StaticIpAttachment)[vs[1].(int)]
   265  	}).(StaticIpAttachmentOutput)
   266  }
   267  
   268  type StaticIpAttachmentMapOutput struct{ *pulumi.OutputState }
   269  
   270  func (StaticIpAttachmentMapOutput) ElementType() reflect.Type {
   271  	return reflect.TypeOf((*map[string]*StaticIpAttachment)(nil)).Elem()
   272  }
   273  
   274  func (o StaticIpAttachmentMapOutput) ToStaticIpAttachmentMapOutput() StaticIpAttachmentMapOutput {
   275  	return o
   276  }
   277  
   278  func (o StaticIpAttachmentMapOutput) ToStaticIpAttachmentMapOutputWithContext(ctx context.Context) StaticIpAttachmentMapOutput {
   279  	return o
   280  }
   281  
   282  func (o StaticIpAttachmentMapOutput) MapIndex(k pulumi.StringInput) StaticIpAttachmentOutput {
   283  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *StaticIpAttachment {
   284  		return vs[0].(map[string]*StaticIpAttachment)[vs[1].(string)]
   285  	}).(StaticIpAttachmentOutput)
   286  }
   287  
   288  func init() {
   289  	pulumi.RegisterInputType(reflect.TypeOf((*StaticIpAttachmentInput)(nil)).Elem(), &StaticIpAttachment{})
   290  	pulumi.RegisterInputType(reflect.TypeOf((*StaticIpAttachmentArrayInput)(nil)).Elem(), StaticIpAttachmentArray{})
   291  	pulumi.RegisterInputType(reflect.TypeOf((*StaticIpAttachmentMapInput)(nil)).Elem(), StaticIpAttachmentMap{})
   292  	pulumi.RegisterOutputType(StaticIpAttachmentOutput{})
   293  	pulumi.RegisterOutputType(StaticIpAttachmentArrayOutput{})
   294  	pulumi.RegisterOutputType(StaticIpAttachmentMapOutput{})
   295  }