github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/directoryservice/serviceRegion.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 directoryservice 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 replicated Region and directory for Multi-Region replication. 16 // Multi-Region replication is only supported for the Enterprise Edition of AWS Managed Microsoft AD. 17 // 18 // ## Example Usage 19 // 20 // <!--Start PulumiCodeChooser --> 21 // ```go 22 // package main 23 // 24 // import ( 25 // 26 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws" 27 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/directoryservice" 28 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 29 // "github.com/pulumi/pulumi-std/sdk/go/std" 30 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 31 // 32 // ) 33 // func main() { 34 // pulumi.Run(func(ctx *pulumi.Context) error { 35 // example, err := aws.GetRegion(ctx, nil, nil); 36 // if err != nil { 37 // return err 38 // } 39 // available, err := aws.GetAvailabilityZones(ctx, &aws.GetAvailabilityZonesArgs{ 40 // State: pulumi.StringRef("available"), 41 // Filters: []aws.GetAvailabilityZonesFilter{ 42 // { 43 // Name: "opt-in-status", 44 // Values: []string{ 45 // "opt-in-not-required", 46 // }, 47 // }, 48 // }, 49 // }, nil); 50 // if err != nil { 51 // return err 52 // } 53 // exampleVpc, err := ec2.NewVpc(ctx, "example", &ec2.VpcArgs{ 54 // CidrBlock: pulumi.String("10.0.0.0/16"), 55 // Tags: pulumi.StringMap{ 56 // "Name": pulumi.String("Primary"), 57 // }, 58 // }) 59 // if err != nil { 60 // return err 61 // } 62 // var exampleSubnet []*ec2.Subnet 63 // 64 // for index := 0; index < 2; index++ { 65 // key0 := index 66 // val0 := index 67 // 68 // __res, err := ec2.NewSubnet(ctx, fmt.Sprintf("example-%v", key0), &ec2.SubnetArgs{ 69 // VpcId: exampleVpc.ID(), 70 // AvailabilityZone: available.Names[val0], 71 // CidrBlock: exampleVpc.CidrBlock.ApplyT(func(cidrBlock string) (std.CidrsubnetResult, error) { 72 // return std.CidrsubnetOutput(ctx, std.CidrsubnetOutputArgs{ 73 // Input: cidrBlock, 74 // Newbits: 8, 75 // Netnum: val0, 76 // }, nil), nil 77 // }).(std.CidrsubnetResultOutput).ApplyT(func(invoke std.CidrsubnetResult) (*string, error) { 78 // return invoke.Result, nil 79 // }).(pulumi.StringPtrOutput), 80 // Tags: pulumi.StringMap{ 81 // "Name": pulumi.String("Primary"), 82 // }, 83 // }) 84 // if err != nil { 85 // return err 86 // } 87 // exampleSubnet = append(exampleSubnet, __res) 88 // } 89 // exampleDirectory, err := directoryservice.NewDirectory(ctx, "example", &directoryservice.DirectoryArgs{ 90 // Name: pulumi.String("example.com"), 91 // Password: pulumi.String("SuperSecretPassw0rd"), 92 // Type: pulumi.String("MicrosoftAD"), 93 // VpcSettings: &directoryservice.DirectoryVpcSettingsArgs{ 94 // VpcId: exampleVpc.ID(), 95 // SubnetIds: %!v(PANIC=Format method: fatal: A failure has occurred: unlowered splat expression @ example.pp:44,17-36), 96 // }, 97 // }) 98 // if err != nil { 99 // return err 100 // } 101 // available_secondary, err := aws.GetAvailabilityZones(ctx, &aws.GetAvailabilityZonesArgs{ 102 // State: pulumi.StringRef("available"), 103 // Filters: []aws.GetAvailabilityZonesFilter{ 104 // { 105 // Name: "opt-in-status", 106 // Values: []string{ 107 // "opt-in-not-required", 108 // }, 109 // }, 110 // }, 111 // }, nil); 112 // if err != nil { 113 // return err 114 // } 115 // _, err = ec2.NewVpc(ctx, "example-secondary", &ec2.VpcArgs{ 116 // CidrBlock: pulumi.String("10.1.0.0/16"), 117 // Tags: pulumi.StringMap{ 118 // "Name": pulumi.String("Secondary"), 119 // }, 120 // }) 121 // if err != nil { 122 // return err 123 // } 124 // var example_secondarySubnet []*ec2.Subnet 125 // 126 // for index := 0; index < 2; index++ { 127 // key0 := index 128 // val0 := index 129 // 130 // __res, err := ec2.NewSubnet(ctx, fmt.Sprintf("example-secondary-%v", key0), &ec2.SubnetArgs{ 131 // VpcId: example_secondary.ID(), 132 // AvailabilityZone: available_secondary.Names[val0], 133 // CidrBlock: example_secondary.CidrBlock.ApplyT(func(cidrBlock string) (std.CidrsubnetResult, error) { 134 // return std.CidrsubnetOutput(ctx, std.CidrsubnetOutputArgs{ 135 // Input: cidrBlock, 136 // Newbits: 8, 137 // Netnum: val0, 138 // }, nil), nil 139 // }).(std.CidrsubnetResultOutput).ApplyT(func(invoke std.CidrsubnetResult) (*string, error) { 140 // return invoke.Result, nil 141 // }).(pulumi.StringPtrOutput), 142 // Tags: pulumi.StringMap{ 143 // "Name": pulumi.String("Secondary"), 144 // }, 145 // }) 146 // if err != nil { 147 // return err 148 // } 149 // example_secondarySubnet = append(example_secondarySubnet, __res) 150 // } 151 // _, err = directoryservice.NewServiceRegion(ctx, "example", &directoryservice.ServiceRegionArgs{ 152 // DirectoryId: exampleDirectory.ID(), 153 // RegionName: pulumi.String(example.Name), 154 // VpcSettings: &directoryservice.ServiceRegionVpcSettingsArgs{ 155 // VpcId: example_secondary.ID(), 156 // SubnetIds: %!v(PANIC=Format method: fatal: A failure has occurred: unlowered splat expression @ example.pp:87,17-46), 157 // }, 158 // Tags: pulumi.StringMap{ 159 // "Name": pulumi.String("Secondary"), 160 // }, 161 // }) 162 // if err != nil { 163 // return err 164 // } 165 // return nil 166 // }) 167 // } 168 // ``` 169 // <!--End PulumiCodeChooser --> 170 // 171 // ## Import 172 // 173 // Using `pulumi import`, import Replicated Regions using directory ID,Region name. For example: 174 // 175 // ```sh 176 // $ pulumi import aws:directoryservice/serviceRegion:ServiceRegion example d-9267651497,us-east-2 177 // ``` 178 type ServiceRegion struct { 179 pulumi.CustomResourceState 180 181 // The number of domain controllers desired in the replicated directory. Minimum value of `2`. 182 DesiredNumberOfDomainControllers pulumi.IntOutput `pulumi:"desiredNumberOfDomainControllers"` 183 // The identifier of the directory to which you want to add Region replication. 184 DirectoryId pulumi.StringOutput `pulumi:"directoryId"` 185 // The name of the Region where you want to add domain controllers for replication. 186 RegionName pulumi.StringOutput `pulumi:"regionName"` 187 // Map of tags to assign to this resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 188 Tags pulumi.StringMapOutput `pulumi:"tags"` 189 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 190 // 191 // Deprecated: Please use `tags` instead. 192 TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"` 193 // VPC information in the replicated Region. Detailed below. 194 VpcSettings ServiceRegionVpcSettingsOutput `pulumi:"vpcSettings"` 195 } 196 197 // NewServiceRegion registers a new resource with the given unique name, arguments, and options. 198 func NewServiceRegion(ctx *pulumi.Context, 199 name string, args *ServiceRegionArgs, opts ...pulumi.ResourceOption) (*ServiceRegion, error) { 200 if args == nil { 201 return nil, errors.New("missing one or more required arguments") 202 } 203 204 if args.DirectoryId == nil { 205 return nil, errors.New("invalid value for required argument 'DirectoryId'") 206 } 207 if args.RegionName == nil { 208 return nil, errors.New("invalid value for required argument 'RegionName'") 209 } 210 if args.VpcSettings == nil { 211 return nil, errors.New("invalid value for required argument 'VpcSettings'") 212 } 213 opts = internal.PkgResourceDefaultOpts(opts) 214 var resource ServiceRegion 215 err := ctx.RegisterResource("aws:directoryservice/serviceRegion:ServiceRegion", name, args, &resource, opts...) 216 if err != nil { 217 return nil, err 218 } 219 return &resource, nil 220 } 221 222 // GetServiceRegion gets an existing ServiceRegion resource's state with the given name, ID, and optional 223 // state properties that are used to uniquely qualify the lookup (nil if not required). 224 func GetServiceRegion(ctx *pulumi.Context, 225 name string, id pulumi.IDInput, state *ServiceRegionState, opts ...pulumi.ResourceOption) (*ServiceRegion, error) { 226 var resource ServiceRegion 227 err := ctx.ReadResource("aws:directoryservice/serviceRegion:ServiceRegion", name, id, state, &resource, opts...) 228 if err != nil { 229 return nil, err 230 } 231 return &resource, nil 232 } 233 234 // Input properties used for looking up and filtering ServiceRegion resources. 235 type serviceRegionState struct { 236 // The number of domain controllers desired in the replicated directory. Minimum value of `2`. 237 DesiredNumberOfDomainControllers *int `pulumi:"desiredNumberOfDomainControllers"` 238 // The identifier of the directory to which you want to add Region replication. 239 DirectoryId *string `pulumi:"directoryId"` 240 // The name of the Region where you want to add domain controllers for replication. 241 RegionName *string `pulumi:"regionName"` 242 // Map of tags to assign to this resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 243 Tags map[string]string `pulumi:"tags"` 244 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 245 // 246 // Deprecated: Please use `tags` instead. 247 TagsAll map[string]string `pulumi:"tagsAll"` 248 // VPC information in the replicated Region. Detailed below. 249 VpcSettings *ServiceRegionVpcSettings `pulumi:"vpcSettings"` 250 } 251 252 type ServiceRegionState struct { 253 // The number of domain controllers desired in the replicated directory. Minimum value of `2`. 254 DesiredNumberOfDomainControllers pulumi.IntPtrInput 255 // The identifier of the directory to which you want to add Region replication. 256 DirectoryId pulumi.StringPtrInput 257 // The name of the Region where you want to add domain controllers for replication. 258 RegionName pulumi.StringPtrInput 259 // Map of tags to assign to this resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 260 Tags pulumi.StringMapInput 261 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 262 // 263 // Deprecated: Please use `tags` instead. 264 TagsAll pulumi.StringMapInput 265 // VPC information in the replicated Region. Detailed below. 266 VpcSettings ServiceRegionVpcSettingsPtrInput 267 } 268 269 func (ServiceRegionState) ElementType() reflect.Type { 270 return reflect.TypeOf((*serviceRegionState)(nil)).Elem() 271 } 272 273 type serviceRegionArgs struct { 274 // The number of domain controllers desired in the replicated directory. Minimum value of `2`. 275 DesiredNumberOfDomainControllers *int `pulumi:"desiredNumberOfDomainControllers"` 276 // The identifier of the directory to which you want to add Region replication. 277 DirectoryId string `pulumi:"directoryId"` 278 // The name of the Region where you want to add domain controllers for replication. 279 RegionName string `pulumi:"regionName"` 280 // Map of tags to assign to this resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 281 Tags map[string]string `pulumi:"tags"` 282 // VPC information in the replicated Region. Detailed below. 283 VpcSettings ServiceRegionVpcSettings `pulumi:"vpcSettings"` 284 } 285 286 // The set of arguments for constructing a ServiceRegion resource. 287 type ServiceRegionArgs struct { 288 // The number of domain controllers desired in the replicated directory. Minimum value of `2`. 289 DesiredNumberOfDomainControllers pulumi.IntPtrInput 290 // The identifier of the directory to which you want to add Region replication. 291 DirectoryId pulumi.StringInput 292 // The name of the Region where you want to add domain controllers for replication. 293 RegionName pulumi.StringInput 294 // Map of tags to assign to this resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 295 Tags pulumi.StringMapInput 296 // VPC information in the replicated Region. Detailed below. 297 VpcSettings ServiceRegionVpcSettingsInput 298 } 299 300 func (ServiceRegionArgs) ElementType() reflect.Type { 301 return reflect.TypeOf((*serviceRegionArgs)(nil)).Elem() 302 } 303 304 type ServiceRegionInput interface { 305 pulumi.Input 306 307 ToServiceRegionOutput() ServiceRegionOutput 308 ToServiceRegionOutputWithContext(ctx context.Context) ServiceRegionOutput 309 } 310 311 func (*ServiceRegion) ElementType() reflect.Type { 312 return reflect.TypeOf((**ServiceRegion)(nil)).Elem() 313 } 314 315 func (i *ServiceRegion) ToServiceRegionOutput() ServiceRegionOutput { 316 return i.ToServiceRegionOutputWithContext(context.Background()) 317 } 318 319 func (i *ServiceRegion) ToServiceRegionOutputWithContext(ctx context.Context) ServiceRegionOutput { 320 return pulumi.ToOutputWithContext(ctx, i).(ServiceRegionOutput) 321 } 322 323 // ServiceRegionArrayInput is an input type that accepts ServiceRegionArray and ServiceRegionArrayOutput values. 324 // You can construct a concrete instance of `ServiceRegionArrayInput` via: 325 // 326 // ServiceRegionArray{ ServiceRegionArgs{...} } 327 type ServiceRegionArrayInput interface { 328 pulumi.Input 329 330 ToServiceRegionArrayOutput() ServiceRegionArrayOutput 331 ToServiceRegionArrayOutputWithContext(context.Context) ServiceRegionArrayOutput 332 } 333 334 type ServiceRegionArray []ServiceRegionInput 335 336 func (ServiceRegionArray) ElementType() reflect.Type { 337 return reflect.TypeOf((*[]*ServiceRegion)(nil)).Elem() 338 } 339 340 func (i ServiceRegionArray) ToServiceRegionArrayOutput() ServiceRegionArrayOutput { 341 return i.ToServiceRegionArrayOutputWithContext(context.Background()) 342 } 343 344 func (i ServiceRegionArray) ToServiceRegionArrayOutputWithContext(ctx context.Context) ServiceRegionArrayOutput { 345 return pulumi.ToOutputWithContext(ctx, i).(ServiceRegionArrayOutput) 346 } 347 348 // ServiceRegionMapInput is an input type that accepts ServiceRegionMap and ServiceRegionMapOutput values. 349 // You can construct a concrete instance of `ServiceRegionMapInput` via: 350 // 351 // ServiceRegionMap{ "key": ServiceRegionArgs{...} } 352 type ServiceRegionMapInput interface { 353 pulumi.Input 354 355 ToServiceRegionMapOutput() ServiceRegionMapOutput 356 ToServiceRegionMapOutputWithContext(context.Context) ServiceRegionMapOutput 357 } 358 359 type ServiceRegionMap map[string]ServiceRegionInput 360 361 func (ServiceRegionMap) ElementType() reflect.Type { 362 return reflect.TypeOf((*map[string]*ServiceRegion)(nil)).Elem() 363 } 364 365 func (i ServiceRegionMap) ToServiceRegionMapOutput() ServiceRegionMapOutput { 366 return i.ToServiceRegionMapOutputWithContext(context.Background()) 367 } 368 369 func (i ServiceRegionMap) ToServiceRegionMapOutputWithContext(ctx context.Context) ServiceRegionMapOutput { 370 return pulumi.ToOutputWithContext(ctx, i).(ServiceRegionMapOutput) 371 } 372 373 type ServiceRegionOutput struct{ *pulumi.OutputState } 374 375 func (ServiceRegionOutput) ElementType() reflect.Type { 376 return reflect.TypeOf((**ServiceRegion)(nil)).Elem() 377 } 378 379 func (o ServiceRegionOutput) ToServiceRegionOutput() ServiceRegionOutput { 380 return o 381 } 382 383 func (o ServiceRegionOutput) ToServiceRegionOutputWithContext(ctx context.Context) ServiceRegionOutput { 384 return o 385 } 386 387 // The number of domain controllers desired in the replicated directory. Minimum value of `2`. 388 func (o ServiceRegionOutput) DesiredNumberOfDomainControllers() pulumi.IntOutput { 389 return o.ApplyT(func(v *ServiceRegion) pulumi.IntOutput { return v.DesiredNumberOfDomainControllers }).(pulumi.IntOutput) 390 } 391 392 // The identifier of the directory to which you want to add Region replication. 393 func (o ServiceRegionOutput) DirectoryId() pulumi.StringOutput { 394 return o.ApplyT(func(v *ServiceRegion) pulumi.StringOutput { return v.DirectoryId }).(pulumi.StringOutput) 395 } 396 397 // The name of the Region where you want to add domain controllers for replication. 398 func (o ServiceRegionOutput) RegionName() pulumi.StringOutput { 399 return o.ApplyT(func(v *ServiceRegion) pulumi.StringOutput { return v.RegionName }).(pulumi.StringOutput) 400 } 401 402 // Map of tags to assign to this resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 403 func (o ServiceRegionOutput) Tags() pulumi.StringMapOutput { 404 return o.ApplyT(func(v *ServiceRegion) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput) 405 } 406 407 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 408 // 409 // Deprecated: Please use `tags` instead. 410 func (o ServiceRegionOutput) TagsAll() pulumi.StringMapOutput { 411 return o.ApplyT(func(v *ServiceRegion) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput) 412 } 413 414 // VPC information in the replicated Region. Detailed below. 415 func (o ServiceRegionOutput) VpcSettings() ServiceRegionVpcSettingsOutput { 416 return o.ApplyT(func(v *ServiceRegion) ServiceRegionVpcSettingsOutput { return v.VpcSettings }).(ServiceRegionVpcSettingsOutput) 417 } 418 419 type ServiceRegionArrayOutput struct{ *pulumi.OutputState } 420 421 func (ServiceRegionArrayOutput) ElementType() reflect.Type { 422 return reflect.TypeOf((*[]*ServiceRegion)(nil)).Elem() 423 } 424 425 func (o ServiceRegionArrayOutput) ToServiceRegionArrayOutput() ServiceRegionArrayOutput { 426 return o 427 } 428 429 func (o ServiceRegionArrayOutput) ToServiceRegionArrayOutputWithContext(ctx context.Context) ServiceRegionArrayOutput { 430 return o 431 } 432 433 func (o ServiceRegionArrayOutput) Index(i pulumi.IntInput) ServiceRegionOutput { 434 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ServiceRegion { 435 return vs[0].([]*ServiceRegion)[vs[1].(int)] 436 }).(ServiceRegionOutput) 437 } 438 439 type ServiceRegionMapOutput struct{ *pulumi.OutputState } 440 441 func (ServiceRegionMapOutput) ElementType() reflect.Type { 442 return reflect.TypeOf((*map[string]*ServiceRegion)(nil)).Elem() 443 } 444 445 func (o ServiceRegionMapOutput) ToServiceRegionMapOutput() ServiceRegionMapOutput { 446 return o 447 } 448 449 func (o ServiceRegionMapOutput) ToServiceRegionMapOutputWithContext(ctx context.Context) ServiceRegionMapOutput { 450 return o 451 } 452 453 func (o ServiceRegionMapOutput) MapIndex(k pulumi.StringInput) ServiceRegionOutput { 454 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ServiceRegion { 455 return vs[0].(map[string]*ServiceRegion)[vs[1].(string)] 456 }).(ServiceRegionOutput) 457 } 458 459 func init() { 460 pulumi.RegisterInputType(reflect.TypeOf((*ServiceRegionInput)(nil)).Elem(), &ServiceRegion{}) 461 pulumi.RegisterInputType(reflect.TypeOf((*ServiceRegionArrayInput)(nil)).Elem(), ServiceRegionArray{}) 462 pulumi.RegisterInputType(reflect.TypeOf((*ServiceRegionMapInput)(nil)).Elem(), ServiceRegionMap{}) 463 pulumi.RegisterOutputType(ServiceRegionOutput{}) 464 pulumi.RegisterOutputType(ServiceRegionArrayOutput{}) 465 pulumi.RegisterOutputType(ServiceRegionMapOutput{}) 466 }