github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/servicediscovery/instance.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 servicediscovery 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 Service Discovery Instance resource. 16 // 17 // ## Example Usage 18 // 19 // <!--Start PulumiCodeChooser --> 20 // ```go 21 // package main 22 // 23 // import ( 24 // 25 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 26 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/servicediscovery" 27 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 28 // 29 // ) 30 // 31 // func main() { 32 // pulumi.Run(func(ctx *pulumi.Context) error { 33 // example, err := ec2.NewVpc(ctx, "example", &ec2.VpcArgs{ 34 // CidrBlock: pulumi.String("10.0.0.0/16"), 35 // EnableDnsSupport: pulumi.Bool(true), 36 // EnableDnsHostnames: pulumi.Bool(true), 37 // }) 38 // if err != nil { 39 // return err 40 // } 41 // examplePrivateDnsNamespace, err := servicediscovery.NewPrivateDnsNamespace(ctx, "example", &servicediscovery.PrivateDnsNamespaceArgs{ 42 // Name: pulumi.String("example.domain.local"), 43 // Description: pulumi.String("example"), 44 // Vpc: example.ID(), 45 // }) 46 // if err != nil { 47 // return err 48 // } 49 // exampleService, err := servicediscovery.NewService(ctx, "example", &servicediscovery.ServiceArgs{ 50 // Name: pulumi.String("example"), 51 // DnsConfig: &servicediscovery.ServiceDnsConfigArgs{ 52 // NamespaceId: examplePrivateDnsNamespace.ID(), 53 // DnsRecords: servicediscovery.ServiceDnsConfigDnsRecordArray{ 54 // &servicediscovery.ServiceDnsConfigDnsRecordArgs{ 55 // Ttl: pulumi.Int(10), 56 // Type: pulumi.String("A"), 57 // }, 58 // }, 59 // RoutingPolicy: pulumi.String("MULTIVALUE"), 60 // }, 61 // HealthCheckCustomConfig: &servicediscovery.ServiceHealthCheckCustomConfigArgs{ 62 // FailureThreshold: pulumi.Int(1), 63 // }, 64 // }) 65 // if err != nil { 66 // return err 67 // } 68 // _, err = servicediscovery.NewInstance(ctx, "example", &servicediscovery.InstanceArgs{ 69 // InstanceId: pulumi.String("example-instance-id"), 70 // ServiceId: exampleService.ID(), 71 // Attributes: pulumi.StringMap{ 72 // "AWS_INSTANCE_IPV4": pulumi.String("172.18.0.1"), 73 // "custom_attribute": pulumi.String("custom"), 74 // }, 75 // }) 76 // if err != nil { 77 // return err 78 // } 79 // return nil 80 // }) 81 // } 82 // 83 // ``` 84 // <!--End PulumiCodeChooser --> 85 // 86 // <!--Start PulumiCodeChooser --> 87 // ```go 88 // package main 89 // 90 // import ( 91 // 92 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/servicediscovery" 93 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 94 // 95 // ) 96 // 97 // func main() { 98 // pulumi.Run(func(ctx *pulumi.Context) error { 99 // example, err := servicediscovery.NewHttpNamespace(ctx, "example", &servicediscovery.HttpNamespaceArgs{ 100 // Name: pulumi.String("example.domain.test"), 101 // Description: pulumi.String("example"), 102 // }) 103 // if err != nil { 104 // return err 105 // } 106 // exampleService, err := servicediscovery.NewService(ctx, "example", &servicediscovery.ServiceArgs{ 107 // Name: pulumi.String("example"), 108 // NamespaceId: example.ID(), 109 // }) 110 // if err != nil { 111 // return err 112 // } 113 // _, err = servicediscovery.NewInstance(ctx, "example", &servicediscovery.InstanceArgs{ 114 // InstanceId: pulumi.String("example-instance-id"), 115 // ServiceId: exampleService.ID(), 116 // Attributes: pulumi.StringMap{ 117 // "AWS_EC2_INSTANCE_ID": pulumi.String("i-0abdg374kd892cj6dl"), 118 // }, 119 // }) 120 // if err != nil { 121 // return err 122 // } 123 // return nil 124 // }) 125 // } 126 // 127 // ``` 128 // <!--End PulumiCodeChooser --> 129 // 130 // ## Import 131 // 132 // Using `pulumi import`, import Service Discovery Instance using the service ID and instance ID. For example: 133 // 134 // ```sh 135 // $ pulumi import aws:servicediscovery/instance:Instance example 0123456789/i-0123 136 // ``` 137 type Instance struct { 138 pulumi.CustomResourceState 139 140 // A map contains the attributes of the instance. Check the [doc](https://docs.aws.amazon.com/cloud-map/latest/api/API_RegisterInstance.html#API_RegisterInstance_RequestSyntax) for the supported attributes and syntax. 141 Attributes pulumi.StringMapOutput `pulumi:"attributes"` 142 // The ID of the service instance. 143 InstanceId pulumi.StringOutput `pulumi:"instanceId"` 144 // The ID of the service that you want to use to create the instance. 145 ServiceId pulumi.StringOutput `pulumi:"serviceId"` 146 } 147 148 // NewInstance registers a new resource with the given unique name, arguments, and options. 149 func NewInstance(ctx *pulumi.Context, 150 name string, args *InstanceArgs, opts ...pulumi.ResourceOption) (*Instance, error) { 151 if args == nil { 152 return nil, errors.New("missing one or more required arguments") 153 } 154 155 if args.Attributes == nil { 156 return nil, errors.New("invalid value for required argument 'Attributes'") 157 } 158 if args.InstanceId == nil { 159 return nil, errors.New("invalid value for required argument 'InstanceId'") 160 } 161 if args.ServiceId == nil { 162 return nil, errors.New("invalid value for required argument 'ServiceId'") 163 } 164 opts = internal.PkgResourceDefaultOpts(opts) 165 var resource Instance 166 err := ctx.RegisterResource("aws:servicediscovery/instance:Instance", name, args, &resource, opts...) 167 if err != nil { 168 return nil, err 169 } 170 return &resource, nil 171 } 172 173 // GetInstance gets an existing Instance resource's state with the given name, ID, and optional 174 // state properties that are used to uniquely qualify the lookup (nil if not required). 175 func GetInstance(ctx *pulumi.Context, 176 name string, id pulumi.IDInput, state *InstanceState, opts ...pulumi.ResourceOption) (*Instance, error) { 177 var resource Instance 178 err := ctx.ReadResource("aws:servicediscovery/instance:Instance", name, id, state, &resource, opts...) 179 if err != nil { 180 return nil, err 181 } 182 return &resource, nil 183 } 184 185 // Input properties used for looking up and filtering Instance resources. 186 type instanceState struct { 187 // A map contains the attributes of the instance. Check the [doc](https://docs.aws.amazon.com/cloud-map/latest/api/API_RegisterInstance.html#API_RegisterInstance_RequestSyntax) for the supported attributes and syntax. 188 Attributes map[string]string `pulumi:"attributes"` 189 // The ID of the service instance. 190 InstanceId *string `pulumi:"instanceId"` 191 // The ID of the service that you want to use to create the instance. 192 ServiceId *string `pulumi:"serviceId"` 193 } 194 195 type InstanceState struct { 196 // A map contains the attributes of the instance. Check the [doc](https://docs.aws.amazon.com/cloud-map/latest/api/API_RegisterInstance.html#API_RegisterInstance_RequestSyntax) for the supported attributes and syntax. 197 Attributes pulumi.StringMapInput 198 // The ID of the service instance. 199 InstanceId pulumi.StringPtrInput 200 // The ID of the service that you want to use to create the instance. 201 ServiceId pulumi.StringPtrInput 202 } 203 204 func (InstanceState) ElementType() reflect.Type { 205 return reflect.TypeOf((*instanceState)(nil)).Elem() 206 } 207 208 type instanceArgs struct { 209 // A map contains the attributes of the instance. Check the [doc](https://docs.aws.amazon.com/cloud-map/latest/api/API_RegisterInstance.html#API_RegisterInstance_RequestSyntax) for the supported attributes and syntax. 210 Attributes map[string]string `pulumi:"attributes"` 211 // The ID of the service instance. 212 InstanceId string `pulumi:"instanceId"` 213 // The ID of the service that you want to use to create the instance. 214 ServiceId string `pulumi:"serviceId"` 215 } 216 217 // The set of arguments for constructing a Instance resource. 218 type InstanceArgs struct { 219 // A map contains the attributes of the instance. Check the [doc](https://docs.aws.amazon.com/cloud-map/latest/api/API_RegisterInstance.html#API_RegisterInstance_RequestSyntax) for the supported attributes and syntax. 220 Attributes pulumi.StringMapInput 221 // The ID of the service instance. 222 InstanceId pulumi.StringInput 223 // The ID of the service that you want to use to create the instance. 224 ServiceId pulumi.StringInput 225 } 226 227 func (InstanceArgs) ElementType() reflect.Type { 228 return reflect.TypeOf((*instanceArgs)(nil)).Elem() 229 } 230 231 type InstanceInput interface { 232 pulumi.Input 233 234 ToInstanceOutput() InstanceOutput 235 ToInstanceOutputWithContext(ctx context.Context) InstanceOutput 236 } 237 238 func (*Instance) ElementType() reflect.Type { 239 return reflect.TypeOf((**Instance)(nil)).Elem() 240 } 241 242 func (i *Instance) ToInstanceOutput() InstanceOutput { 243 return i.ToInstanceOutputWithContext(context.Background()) 244 } 245 246 func (i *Instance) ToInstanceOutputWithContext(ctx context.Context) InstanceOutput { 247 return pulumi.ToOutputWithContext(ctx, i).(InstanceOutput) 248 } 249 250 // InstanceArrayInput is an input type that accepts InstanceArray and InstanceArrayOutput values. 251 // You can construct a concrete instance of `InstanceArrayInput` via: 252 // 253 // InstanceArray{ InstanceArgs{...} } 254 type InstanceArrayInput interface { 255 pulumi.Input 256 257 ToInstanceArrayOutput() InstanceArrayOutput 258 ToInstanceArrayOutputWithContext(context.Context) InstanceArrayOutput 259 } 260 261 type InstanceArray []InstanceInput 262 263 func (InstanceArray) ElementType() reflect.Type { 264 return reflect.TypeOf((*[]*Instance)(nil)).Elem() 265 } 266 267 func (i InstanceArray) ToInstanceArrayOutput() InstanceArrayOutput { 268 return i.ToInstanceArrayOutputWithContext(context.Background()) 269 } 270 271 func (i InstanceArray) ToInstanceArrayOutputWithContext(ctx context.Context) InstanceArrayOutput { 272 return pulumi.ToOutputWithContext(ctx, i).(InstanceArrayOutput) 273 } 274 275 // InstanceMapInput is an input type that accepts InstanceMap and InstanceMapOutput values. 276 // You can construct a concrete instance of `InstanceMapInput` via: 277 // 278 // InstanceMap{ "key": InstanceArgs{...} } 279 type InstanceMapInput interface { 280 pulumi.Input 281 282 ToInstanceMapOutput() InstanceMapOutput 283 ToInstanceMapOutputWithContext(context.Context) InstanceMapOutput 284 } 285 286 type InstanceMap map[string]InstanceInput 287 288 func (InstanceMap) ElementType() reflect.Type { 289 return reflect.TypeOf((*map[string]*Instance)(nil)).Elem() 290 } 291 292 func (i InstanceMap) ToInstanceMapOutput() InstanceMapOutput { 293 return i.ToInstanceMapOutputWithContext(context.Background()) 294 } 295 296 func (i InstanceMap) ToInstanceMapOutputWithContext(ctx context.Context) InstanceMapOutput { 297 return pulumi.ToOutputWithContext(ctx, i).(InstanceMapOutput) 298 } 299 300 type InstanceOutput struct{ *pulumi.OutputState } 301 302 func (InstanceOutput) ElementType() reflect.Type { 303 return reflect.TypeOf((**Instance)(nil)).Elem() 304 } 305 306 func (o InstanceOutput) ToInstanceOutput() InstanceOutput { 307 return o 308 } 309 310 func (o InstanceOutput) ToInstanceOutputWithContext(ctx context.Context) InstanceOutput { 311 return o 312 } 313 314 // A map contains the attributes of the instance. Check the [doc](https://docs.aws.amazon.com/cloud-map/latest/api/API_RegisterInstance.html#API_RegisterInstance_RequestSyntax) for the supported attributes and syntax. 315 func (o InstanceOutput) Attributes() pulumi.StringMapOutput { 316 return o.ApplyT(func(v *Instance) pulumi.StringMapOutput { return v.Attributes }).(pulumi.StringMapOutput) 317 } 318 319 // The ID of the service instance. 320 func (o InstanceOutput) InstanceId() pulumi.StringOutput { 321 return o.ApplyT(func(v *Instance) pulumi.StringOutput { return v.InstanceId }).(pulumi.StringOutput) 322 } 323 324 // The ID of the service that you want to use to create the instance. 325 func (o InstanceOutput) ServiceId() pulumi.StringOutput { 326 return o.ApplyT(func(v *Instance) pulumi.StringOutput { return v.ServiceId }).(pulumi.StringOutput) 327 } 328 329 type InstanceArrayOutput struct{ *pulumi.OutputState } 330 331 func (InstanceArrayOutput) ElementType() reflect.Type { 332 return reflect.TypeOf((*[]*Instance)(nil)).Elem() 333 } 334 335 func (o InstanceArrayOutput) ToInstanceArrayOutput() InstanceArrayOutput { 336 return o 337 } 338 339 func (o InstanceArrayOutput) ToInstanceArrayOutputWithContext(ctx context.Context) InstanceArrayOutput { 340 return o 341 } 342 343 func (o InstanceArrayOutput) Index(i pulumi.IntInput) InstanceOutput { 344 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Instance { 345 return vs[0].([]*Instance)[vs[1].(int)] 346 }).(InstanceOutput) 347 } 348 349 type InstanceMapOutput struct{ *pulumi.OutputState } 350 351 func (InstanceMapOutput) ElementType() reflect.Type { 352 return reflect.TypeOf((*map[string]*Instance)(nil)).Elem() 353 } 354 355 func (o InstanceMapOutput) ToInstanceMapOutput() InstanceMapOutput { 356 return o 357 } 358 359 func (o InstanceMapOutput) ToInstanceMapOutputWithContext(ctx context.Context) InstanceMapOutput { 360 return o 361 } 362 363 func (o InstanceMapOutput) MapIndex(k pulumi.StringInput) InstanceOutput { 364 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Instance { 365 return vs[0].(map[string]*Instance)[vs[1].(string)] 366 }).(InstanceOutput) 367 } 368 369 func init() { 370 pulumi.RegisterInputType(reflect.TypeOf((*InstanceInput)(nil)).Elem(), &Instance{}) 371 pulumi.RegisterInputType(reflect.TypeOf((*InstanceArrayInput)(nil)).Elem(), InstanceArray{}) 372 pulumi.RegisterInputType(reflect.TypeOf((*InstanceMapInput)(nil)).Elem(), InstanceMap{}) 373 pulumi.RegisterOutputType(InstanceOutput{}) 374 pulumi.RegisterOutputType(InstanceArrayOutput{}) 375 pulumi.RegisterOutputType(InstanceMapOutput{}) 376 }