github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/route53/zoneAssociation.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 route53
     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  // Manages a Route53 Hosted Zone VPC association. VPC associations can only be made on private zones. See the `route53.VpcAssociationAuthorization` resource for setting up cross-account associations.
    16  //
    17  // > **NOTE:** Unless explicit association ordering is required (e.g., a separate cross-account association authorization), usage of this resource is not recommended. Use the `vpc` configuration blocks available within the `route53.Zone` resource instead.
    18  //
    19  // > **NOTE:** This provider provides both this standalone Zone VPC Association resource and exclusive VPC associations defined in-line in the `route53.Zone` resource via `vpc` configuration blocks. At this time, you cannot use those in-line VPC associations in conjunction with this resource and the same zone ID otherwise it will cause a perpetual difference in plan output. You can optionally use [`ignoreChanges`](https://www.pulumi.com/docs/intro/concepts/programming-model/#ignorechanges) in the `route53.Zone` resource to manage additional associations via this resource.
    20  //
    21  // ## Example Usage
    22  //
    23  // <!--Start PulumiCodeChooser -->
    24  // ```go
    25  // package main
    26  //
    27  // import (
    28  //
    29  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    30  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/route53"
    31  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    32  //
    33  // )
    34  //
    35  //	func main() {
    36  //		pulumi.Run(func(ctx *pulumi.Context) error {
    37  //			primary, err := ec2.NewVpc(ctx, "primary", &ec2.VpcArgs{
    38  //				CidrBlock:          pulumi.String("10.6.0.0/16"),
    39  //				EnableDnsHostnames: pulumi.Bool(true),
    40  //				EnableDnsSupport:   pulumi.Bool(true),
    41  //			})
    42  //			if err != nil {
    43  //				return err
    44  //			}
    45  //			secondary, err := ec2.NewVpc(ctx, "secondary", &ec2.VpcArgs{
    46  //				CidrBlock:          pulumi.String("10.7.0.0/16"),
    47  //				EnableDnsHostnames: pulumi.Bool(true),
    48  //				EnableDnsSupport:   pulumi.Bool(true),
    49  //			})
    50  //			if err != nil {
    51  //				return err
    52  //			}
    53  //			example, err := route53.NewZone(ctx, "example", &route53.ZoneArgs{
    54  //				Name: pulumi.String("example.com"),
    55  //				Vpcs: route53.ZoneVpcArray{
    56  //					&route53.ZoneVpcArgs{
    57  //						VpcId: primary.ID(),
    58  //					},
    59  //				},
    60  //			})
    61  //			if err != nil {
    62  //				return err
    63  //			}
    64  //			_, err = route53.NewZoneAssociation(ctx, "secondary", &route53.ZoneAssociationArgs{
    65  //				ZoneId: example.ZoneId,
    66  //				VpcId:  secondary.ID(),
    67  //			})
    68  //			if err != nil {
    69  //				return err
    70  //			}
    71  //			return nil
    72  //		})
    73  //	}
    74  //
    75  // ```
    76  // <!--End PulumiCodeChooser -->
    77  //
    78  // ## Import
    79  //
    80  // The VPC is _not_ in the same region where you have configured the AWS Provider:
    81  //
    82  // __Using `pulumi import` to import__ Route 53 Hosted Zone Associations using the Hosted Zone ID and VPC ID, separated by a colon (`:`). For example:
    83  //
    84  // The VPC is in the same region where you have configured the AWS Provider:
    85  //
    86  // ```sh
    87  // $ pulumi import aws:route53/zoneAssociation:ZoneAssociation example Z123456ABCDEFG:vpc-12345678
    88  // ```
    89  // The VPC is _not_ in the same region where you have configured the AWS Provider:
    90  //
    91  // ```sh
    92  // $ pulumi import aws:route53/zoneAssociation:ZoneAssociation example Z123456ABCDEFG:vpc-12345678:us-east-2
    93  // ```
    94  type ZoneAssociation struct {
    95  	pulumi.CustomResourceState
    96  
    97  	// The account ID of the account that created the hosted zone.
    98  	OwningAccount pulumi.StringOutput `pulumi:"owningAccount"`
    99  	// The VPC to associate with the private hosted zone.
   100  	VpcId pulumi.StringOutput `pulumi:"vpcId"`
   101  	// The VPC's region. Defaults to the region of the AWS provider.
   102  	VpcRegion pulumi.StringOutput `pulumi:"vpcRegion"`
   103  	// The private hosted zone to associate.
   104  	ZoneId pulumi.StringOutput `pulumi:"zoneId"`
   105  }
   106  
   107  // NewZoneAssociation registers a new resource with the given unique name, arguments, and options.
   108  func NewZoneAssociation(ctx *pulumi.Context,
   109  	name string, args *ZoneAssociationArgs, opts ...pulumi.ResourceOption) (*ZoneAssociation, error) {
   110  	if args == nil {
   111  		return nil, errors.New("missing one or more required arguments")
   112  	}
   113  
   114  	if args.VpcId == nil {
   115  		return nil, errors.New("invalid value for required argument 'VpcId'")
   116  	}
   117  	if args.ZoneId == nil {
   118  		return nil, errors.New("invalid value for required argument 'ZoneId'")
   119  	}
   120  	opts = internal.PkgResourceDefaultOpts(opts)
   121  	var resource ZoneAssociation
   122  	err := ctx.RegisterResource("aws:route53/zoneAssociation:ZoneAssociation", name, args, &resource, opts...)
   123  	if err != nil {
   124  		return nil, err
   125  	}
   126  	return &resource, nil
   127  }
   128  
   129  // GetZoneAssociation gets an existing ZoneAssociation resource's state with the given name, ID, and optional
   130  // state properties that are used to uniquely qualify the lookup (nil if not required).
   131  func GetZoneAssociation(ctx *pulumi.Context,
   132  	name string, id pulumi.IDInput, state *ZoneAssociationState, opts ...pulumi.ResourceOption) (*ZoneAssociation, error) {
   133  	var resource ZoneAssociation
   134  	err := ctx.ReadResource("aws:route53/zoneAssociation:ZoneAssociation", name, id, state, &resource, opts...)
   135  	if err != nil {
   136  		return nil, err
   137  	}
   138  	return &resource, nil
   139  }
   140  
   141  // Input properties used for looking up and filtering ZoneAssociation resources.
   142  type zoneAssociationState struct {
   143  	// The account ID of the account that created the hosted zone.
   144  	OwningAccount *string `pulumi:"owningAccount"`
   145  	// The VPC to associate with the private hosted zone.
   146  	VpcId *string `pulumi:"vpcId"`
   147  	// The VPC's region. Defaults to the region of the AWS provider.
   148  	VpcRegion *string `pulumi:"vpcRegion"`
   149  	// The private hosted zone to associate.
   150  	ZoneId *string `pulumi:"zoneId"`
   151  }
   152  
   153  type ZoneAssociationState struct {
   154  	// The account ID of the account that created the hosted zone.
   155  	OwningAccount pulumi.StringPtrInput
   156  	// The VPC to associate with the private hosted zone.
   157  	VpcId pulumi.StringPtrInput
   158  	// The VPC's region. Defaults to the region of the AWS provider.
   159  	VpcRegion pulumi.StringPtrInput
   160  	// The private hosted zone to associate.
   161  	ZoneId pulumi.StringPtrInput
   162  }
   163  
   164  func (ZoneAssociationState) ElementType() reflect.Type {
   165  	return reflect.TypeOf((*zoneAssociationState)(nil)).Elem()
   166  }
   167  
   168  type zoneAssociationArgs struct {
   169  	// The VPC to associate with the private hosted zone.
   170  	VpcId string `pulumi:"vpcId"`
   171  	// The VPC's region. Defaults to the region of the AWS provider.
   172  	VpcRegion *string `pulumi:"vpcRegion"`
   173  	// The private hosted zone to associate.
   174  	ZoneId string `pulumi:"zoneId"`
   175  }
   176  
   177  // The set of arguments for constructing a ZoneAssociation resource.
   178  type ZoneAssociationArgs struct {
   179  	// The VPC to associate with the private hosted zone.
   180  	VpcId pulumi.StringInput
   181  	// The VPC's region. Defaults to the region of the AWS provider.
   182  	VpcRegion pulumi.StringPtrInput
   183  	// The private hosted zone to associate.
   184  	ZoneId pulumi.StringInput
   185  }
   186  
   187  func (ZoneAssociationArgs) ElementType() reflect.Type {
   188  	return reflect.TypeOf((*zoneAssociationArgs)(nil)).Elem()
   189  }
   190  
   191  type ZoneAssociationInput interface {
   192  	pulumi.Input
   193  
   194  	ToZoneAssociationOutput() ZoneAssociationOutput
   195  	ToZoneAssociationOutputWithContext(ctx context.Context) ZoneAssociationOutput
   196  }
   197  
   198  func (*ZoneAssociation) ElementType() reflect.Type {
   199  	return reflect.TypeOf((**ZoneAssociation)(nil)).Elem()
   200  }
   201  
   202  func (i *ZoneAssociation) ToZoneAssociationOutput() ZoneAssociationOutput {
   203  	return i.ToZoneAssociationOutputWithContext(context.Background())
   204  }
   205  
   206  func (i *ZoneAssociation) ToZoneAssociationOutputWithContext(ctx context.Context) ZoneAssociationOutput {
   207  	return pulumi.ToOutputWithContext(ctx, i).(ZoneAssociationOutput)
   208  }
   209  
   210  // ZoneAssociationArrayInput is an input type that accepts ZoneAssociationArray and ZoneAssociationArrayOutput values.
   211  // You can construct a concrete instance of `ZoneAssociationArrayInput` via:
   212  //
   213  //	ZoneAssociationArray{ ZoneAssociationArgs{...} }
   214  type ZoneAssociationArrayInput interface {
   215  	pulumi.Input
   216  
   217  	ToZoneAssociationArrayOutput() ZoneAssociationArrayOutput
   218  	ToZoneAssociationArrayOutputWithContext(context.Context) ZoneAssociationArrayOutput
   219  }
   220  
   221  type ZoneAssociationArray []ZoneAssociationInput
   222  
   223  func (ZoneAssociationArray) ElementType() reflect.Type {
   224  	return reflect.TypeOf((*[]*ZoneAssociation)(nil)).Elem()
   225  }
   226  
   227  func (i ZoneAssociationArray) ToZoneAssociationArrayOutput() ZoneAssociationArrayOutput {
   228  	return i.ToZoneAssociationArrayOutputWithContext(context.Background())
   229  }
   230  
   231  func (i ZoneAssociationArray) ToZoneAssociationArrayOutputWithContext(ctx context.Context) ZoneAssociationArrayOutput {
   232  	return pulumi.ToOutputWithContext(ctx, i).(ZoneAssociationArrayOutput)
   233  }
   234  
   235  // ZoneAssociationMapInput is an input type that accepts ZoneAssociationMap and ZoneAssociationMapOutput values.
   236  // You can construct a concrete instance of `ZoneAssociationMapInput` via:
   237  //
   238  //	ZoneAssociationMap{ "key": ZoneAssociationArgs{...} }
   239  type ZoneAssociationMapInput interface {
   240  	pulumi.Input
   241  
   242  	ToZoneAssociationMapOutput() ZoneAssociationMapOutput
   243  	ToZoneAssociationMapOutputWithContext(context.Context) ZoneAssociationMapOutput
   244  }
   245  
   246  type ZoneAssociationMap map[string]ZoneAssociationInput
   247  
   248  func (ZoneAssociationMap) ElementType() reflect.Type {
   249  	return reflect.TypeOf((*map[string]*ZoneAssociation)(nil)).Elem()
   250  }
   251  
   252  func (i ZoneAssociationMap) ToZoneAssociationMapOutput() ZoneAssociationMapOutput {
   253  	return i.ToZoneAssociationMapOutputWithContext(context.Background())
   254  }
   255  
   256  func (i ZoneAssociationMap) ToZoneAssociationMapOutputWithContext(ctx context.Context) ZoneAssociationMapOutput {
   257  	return pulumi.ToOutputWithContext(ctx, i).(ZoneAssociationMapOutput)
   258  }
   259  
   260  type ZoneAssociationOutput struct{ *pulumi.OutputState }
   261  
   262  func (ZoneAssociationOutput) ElementType() reflect.Type {
   263  	return reflect.TypeOf((**ZoneAssociation)(nil)).Elem()
   264  }
   265  
   266  func (o ZoneAssociationOutput) ToZoneAssociationOutput() ZoneAssociationOutput {
   267  	return o
   268  }
   269  
   270  func (o ZoneAssociationOutput) ToZoneAssociationOutputWithContext(ctx context.Context) ZoneAssociationOutput {
   271  	return o
   272  }
   273  
   274  // The account ID of the account that created the hosted zone.
   275  func (o ZoneAssociationOutput) OwningAccount() pulumi.StringOutput {
   276  	return o.ApplyT(func(v *ZoneAssociation) pulumi.StringOutput { return v.OwningAccount }).(pulumi.StringOutput)
   277  }
   278  
   279  // The VPC to associate with the private hosted zone.
   280  func (o ZoneAssociationOutput) VpcId() pulumi.StringOutput {
   281  	return o.ApplyT(func(v *ZoneAssociation) pulumi.StringOutput { return v.VpcId }).(pulumi.StringOutput)
   282  }
   283  
   284  // The VPC's region. Defaults to the region of the AWS provider.
   285  func (o ZoneAssociationOutput) VpcRegion() pulumi.StringOutput {
   286  	return o.ApplyT(func(v *ZoneAssociation) pulumi.StringOutput { return v.VpcRegion }).(pulumi.StringOutput)
   287  }
   288  
   289  // The private hosted zone to associate.
   290  func (o ZoneAssociationOutput) ZoneId() pulumi.StringOutput {
   291  	return o.ApplyT(func(v *ZoneAssociation) pulumi.StringOutput { return v.ZoneId }).(pulumi.StringOutput)
   292  }
   293  
   294  type ZoneAssociationArrayOutput struct{ *pulumi.OutputState }
   295  
   296  func (ZoneAssociationArrayOutput) ElementType() reflect.Type {
   297  	return reflect.TypeOf((*[]*ZoneAssociation)(nil)).Elem()
   298  }
   299  
   300  func (o ZoneAssociationArrayOutput) ToZoneAssociationArrayOutput() ZoneAssociationArrayOutput {
   301  	return o
   302  }
   303  
   304  func (o ZoneAssociationArrayOutput) ToZoneAssociationArrayOutputWithContext(ctx context.Context) ZoneAssociationArrayOutput {
   305  	return o
   306  }
   307  
   308  func (o ZoneAssociationArrayOutput) Index(i pulumi.IntInput) ZoneAssociationOutput {
   309  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ZoneAssociation {
   310  		return vs[0].([]*ZoneAssociation)[vs[1].(int)]
   311  	}).(ZoneAssociationOutput)
   312  }
   313  
   314  type ZoneAssociationMapOutput struct{ *pulumi.OutputState }
   315  
   316  func (ZoneAssociationMapOutput) ElementType() reflect.Type {
   317  	return reflect.TypeOf((*map[string]*ZoneAssociation)(nil)).Elem()
   318  }
   319  
   320  func (o ZoneAssociationMapOutput) ToZoneAssociationMapOutput() ZoneAssociationMapOutput {
   321  	return o
   322  }
   323  
   324  func (o ZoneAssociationMapOutput) ToZoneAssociationMapOutputWithContext(ctx context.Context) ZoneAssociationMapOutput {
   325  	return o
   326  }
   327  
   328  func (o ZoneAssociationMapOutput) MapIndex(k pulumi.StringInput) ZoneAssociationOutput {
   329  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ZoneAssociation {
   330  		return vs[0].(map[string]*ZoneAssociation)[vs[1].(string)]
   331  	}).(ZoneAssociationOutput)
   332  }
   333  
   334  func init() {
   335  	pulumi.RegisterInputType(reflect.TypeOf((*ZoneAssociationInput)(nil)).Elem(), &ZoneAssociation{})
   336  	pulumi.RegisterInputType(reflect.TypeOf((*ZoneAssociationArrayInput)(nil)).Elem(), ZoneAssociationArray{})
   337  	pulumi.RegisterInputType(reflect.TypeOf((*ZoneAssociationMapInput)(nil)).Elem(), ZoneAssociationMap{})
   338  	pulumi.RegisterOutputType(ZoneAssociationOutput{})
   339  	pulumi.RegisterOutputType(ZoneAssociationArrayOutput{})
   340  	pulumi.RegisterOutputType(ZoneAssociationMapOutput{})
   341  }