aws.servicediscovery.Instance
Explore with Pulumi AI
Provides a Service Discovery Instance resource.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.ec2.Vpc("example", {
    cidrBlock: "10.0.0.0/16",
    enableDnsSupport: true,
    enableDnsHostnames: true,
});
const examplePrivateDnsNamespace = new aws.servicediscovery.PrivateDnsNamespace("example", {
    name: "example.domain.local",
    description: "example",
    vpc: example.id,
});
const exampleService = new aws.servicediscovery.Service("example", {
    name: "example",
    dnsConfig: {
        namespaceId: examplePrivateDnsNamespace.id,
        dnsRecords: [{
            ttl: 10,
            type: "A",
        }],
        routingPolicy: "MULTIVALUE",
    },
    healthCheckCustomConfig: {
        failureThreshold: 1,
    },
});
const exampleInstance = new aws.servicediscovery.Instance("example", {
    instanceId: "example-instance-id",
    serviceId: exampleService.id,
    attributes: {
        AWS_INSTANCE_IPV4: "172.18.0.1",
        custom_attribute: "custom",
    },
});
import pulumi
import pulumi_aws as aws
example = aws.ec2.Vpc("example",
    cidr_block="10.0.0.0/16",
    enable_dns_support=True,
    enable_dns_hostnames=True)
example_private_dns_namespace = aws.servicediscovery.PrivateDnsNamespace("example",
    name="example.domain.local",
    description="example",
    vpc=example.id)
example_service = aws.servicediscovery.Service("example",
    name="example",
    dns_config={
        "namespace_id": example_private_dns_namespace.id,
        "dns_records": [{
            "ttl": 10,
            "type": "A",
        }],
        "routing_policy": "MULTIVALUE",
    },
    health_check_custom_config={
        "failure_threshold": 1,
    })
example_instance = aws.servicediscovery.Instance("example",
    instance_id="example-instance-id",
    service_id=example_service.id,
    attributes={
        "AWS_INSTANCE_IPV4": "172.18.0.1",
        "custom_attribute": "custom",
    })
package main
import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/servicediscovery"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := ec2.NewVpc(ctx, "example", &ec2.VpcArgs{
			CidrBlock:          pulumi.String("10.0.0.0/16"),
			EnableDnsSupport:   pulumi.Bool(true),
			EnableDnsHostnames: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		examplePrivateDnsNamespace, err := servicediscovery.NewPrivateDnsNamespace(ctx, "example", &servicediscovery.PrivateDnsNamespaceArgs{
			Name:        pulumi.String("example.domain.local"),
			Description: pulumi.String("example"),
			Vpc:         example.ID(),
		})
		if err != nil {
			return err
		}
		exampleService, err := servicediscovery.NewService(ctx, "example", &servicediscovery.ServiceArgs{
			Name: pulumi.String("example"),
			DnsConfig: &servicediscovery.ServiceDnsConfigArgs{
				NamespaceId: examplePrivateDnsNamespace.ID(),
				DnsRecords: servicediscovery.ServiceDnsConfigDnsRecordArray{
					&servicediscovery.ServiceDnsConfigDnsRecordArgs{
						Ttl:  pulumi.Int(10),
						Type: pulumi.String("A"),
					},
				},
				RoutingPolicy: pulumi.String("MULTIVALUE"),
			},
			HealthCheckCustomConfig: &servicediscovery.ServiceHealthCheckCustomConfigArgs{
				FailureThreshold: pulumi.Int(1),
			},
		})
		if err != nil {
			return err
		}
		_, err = servicediscovery.NewInstance(ctx, "example", &servicediscovery.InstanceArgs{
			InstanceId: pulumi.String("example-instance-id"),
			ServiceId:  exampleService.ID(),
			Attributes: pulumi.StringMap{
				"AWS_INSTANCE_IPV4": pulumi.String("172.18.0.1"),
				"custom_attribute":  pulumi.String("custom"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() => 
{
    var example = new Aws.Ec2.Vpc("example", new()
    {
        CidrBlock = "10.0.0.0/16",
        EnableDnsSupport = true,
        EnableDnsHostnames = true,
    });
    var examplePrivateDnsNamespace = new Aws.ServiceDiscovery.PrivateDnsNamespace("example", new()
    {
        Name = "example.domain.local",
        Description = "example",
        Vpc = example.Id,
    });
    var exampleService = new Aws.ServiceDiscovery.Service("example", new()
    {
        Name = "example",
        DnsConfig = new Aws.ServiceDiscovery.Inputs.ServiceDnsConfigArgs
        {
            NamespaceId = examplePrivateDnsNamespace.Id,
            DnsRecords = new[]
            {
                new Aws.ServiceDiscovery.Inputs.ServiceDnsConfigDnsRecordArgs
                {
                    Ttl = 10,
                    Type = "A",
                },
            },
            RoutingPolicy = "MULTIVALUE",
        },
        HealthCheckCustomConfig = new Aws.ServiceDiscovery.Inputs.ServiceHealthCheckCustomConfigArgs
        {
            FailureThreshold = 1,
        },
    });
    var exampleInstance = new Aws.ServiceDiscovery.Instance("example", new()
    {
        InstanceId = "example-instance-id",
        ServiceId = exampleService.Id,
        Attributes = 
        {
            { "AWS_INSTANCE_IPV4", "172.18.0.1" },
            { "custom_attribute", "custom" },
        },
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Vpc;
import com.pulumi.aws.ec2.VpcArgs;
import com.pulumi.aws.servicediscovery.PrivateDnsNamespace;
import com.pulumi.aws.servicediscovery.PrivateDnsNamespaceArgs;
import com.pulumi.aws.servicediscovery.Service;
import com.pulumi.aws.servicediscovery.ServiceArgs;
import com.pulumi.aws.servicediscovery.inputs.ServiceDnsConfigArgs;
import com.pulumi.aws.servicediscovery.inputs.ServiceHealthCheckCustomConfigArgs;
import com.pulumi.aws.servicediscovery.Instance;
import com.pulumi.aws.servicediscovery.InstanceArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        var example = new Vpc("example", VpcArgs.builder()
            .cidrBlock("10.0.0.0/16")
            .enableDnsSupport(true)
            .enableDnsHostnames(true)
            .build());
        var examplePrivateDnsNamespace = new PrivateDnsNamespace("examplePrivateDnsNamespace", PrivateDnsNamespaceArgs.builder()
            .name("example.domain.local")
            .description("example")
            .vpc(example.id())
            .build());
        var exampleService = new Service("exampleService", ServiceArgs.builder()
            .name("example")
            .dnsConfig(ServiceDnsConfigArgs.builder()
                .namespaceId(examplePrivateDnsNamespace.id())
                .dnsRecords(ServiceDnsConfigDnsRecordArgs.builder()
                    .ttl(10)
                    .type("A")
                    .build())
                .routingPolicy("MULTIVALUE")
                .build())
            .healthCheckCustomConfig(ServiceHealthCheckCustomConfigArgs.builder()
                .failureThreshold(1)
                .build())
            .build());
        var exampleInstance = new Instance("exampleInstance", InstanceArgs.builder()
            .instanceId("example-instance-id")
            .serviceId(exampleService.id())
            .attributes(Map.ofEntries(
                Map.entry("AWS_INSTANCE_IPV4", "172.18.0.1"),
                Map.entry("custom_attribute", "custom")
            ))
            .build());
    }
}
resources:
  example:
    type: aws:ec2:Vpc
    properties:
      cidrBlock: 10.0.0.0/16
      enableDnsSupport: true
      enableDnsHostnames: true
  examplePrivateDnsNamespace:
    type: aws:servicediscovery:PrivateDnsNamespace
    name: example
    properties:
      name: example.domain.local
      description: example
      vpc: ${example.id}
  exampleService:
    type: aws:servicediscovery:Service
    name: example
    properties:
      name: example
      dnsConfig:
        namespaceId: ${examplePrivateDnsNamespace.id}
        dnsRecords:
          - ttl: 10
            type: A
        routingPolicy: MULTIVALUE
      healthCheckCustomConfig:
        failureThreshold: 1
  exampleInstance:
    type: aws:servicediscovery:Instance
    name: example
    properties:
      instanceId: example-instance-id
      serviceId: ${exampleService.id}
      attributes:
        AWS_INSTANCE_IPV4: 172.18.0.1
        custom_attribute: custom
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.servicediscovery.HttpNamespace("example", {
    name: "example.domain.test",
    description: "example",
});
const exampleService = new aws.servicediscovery.Service("example", {
    name: "example",
    namespaceId: example.id,
});
const exampleInstance = new aws.servicediscovery.Instance("example", {
    instanceId: "example-instance-id",
    serviceId: exampleService.id,
    attributes: {
        AWS_EC2_INSTANCE_ID: "i-0abdg374kd892cj6dl",
    },
});
import pulumi
import pulumi_aws as aws
example = aws.servicediscovery.HttpNamespace("example",
    name="example.domain.test",
    description="example")
example_service = aws.servicediscovery.Service("example",
    name="example",
    namespace_id=example.id)
example_instance = aws.servicediscovery.Instance("example",
    instance_id="example-instance-id",
    service_id=example_service.id,
    attributes={
        "AWS_EC2_INSTANCE_ID": "i-0abdg374kd892cj6dl",
    })
package main
import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/servicediscovery"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := servicediscovery.NewHttpNamespace(ctx, "example", &servicediscovery.HttpNamespaceArgs{
			Name:        pulumi.String("example.domain.test"),
			Description: pulumi.String("example"),
		})
		if err != nil {
			return err
		}
		exampleService, err := servicediscovery.NewService(ctx, "example", &servicediscovery.ServiceArgs{
			Name:        pulumi.String("example"),
			NamespaceId: example.ID(),
		})
		if err != nil {
			return err
		}
		_, err = servicediscovery.NewInstance(ctx, "example", &servicediscovery.InstanceArgs{
			InstanceId: pulumi.String("example-instance-id"),
			ServiceId:  exampleService.ID(),
			Attributes: pulumi.StringMap{
				"AWS_EC2_INSTANCE_ID": pulumi.String("i-0abdg374kd892cj6dl"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() => 
{
    var example = new Aws.ServiceDiscovery.HttpNamespace("example", new()
    {
        Name = "example.domain.test",
        Description = "example",
    });
    var exampleService = new Aws.ServiceDiscovery.Service("example", new()
    {
        Name = "example",
        NamespaceId = example.Id,
    });
    var exampleInstance = new Aws.ServiceDiscovery.Instance("example", new()
    {
        InstanceId = "example-instance-id",
        ServiceId = exampleService.Id,
        Attributes = 
        {
            { "AWS_EC2_INSTANCE_ID", "i-0abdg374kd892cj6dl" },
        },
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.servicediscovery.HttpNamespace;
import com.pulumi.aws.servicediscovery.HttpNamespaceArgs;
import com.pulumi.aws.servicediscovery.Service;
import com.pulumi.aws.servicediscovery.ServiceArgs;
import com.pulumi.aws.servicediscovery.Instance;
import com.pulumi.aws.servicediscovery.InstanceArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        var example = new HttpNamespace("example", HttpNamespaceArgs.builder()
            .name("example.domain.test")
            .description("example")
            .build());
        var exampleService = new Service("exampleService", ServiceArgs.builder()
            .name("example")
            .namespaceId(example.id())
            .build());
        var exampleInstance = new Instance("exampleInstance", InstanceArgs.builder()
            .instanceId("example-instance-id")
            .serviceId(exampleService.id())
            .attributes(Map.of("AWS_EC2_INSTANCE_ID", "i-0abdg374kd892cj6dl"))
            .build());
    }
}
resources:
  example:
    type: aws:servicediscovery:HttpNamespace
    properties:
      name: example.domain.test
      description: example
  exampleService:
    type: aws:servicediscovery:Service
    name: example
    properties:
      name: example
      namespaceId: ${example.id}
  exampleInstance:
    type: aws:servicediscovery:Instance
    name: example
    properties:
      instanceId: example-instance-id
      serviceId: ${exampleService.id}
      attributes:
        AWS_EC2_INSTANCE_ID: i-0abdg374kd892cj6dl
Create Instance Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Instance(name: string, args: InstanceArgs, opts?: CustomResourceOptions);@overload
def Instance(resource_name: str,
             args: InstanceArgs,
             opts: Optional[ResourceOptions] = None)
@overload
def Instance(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             attributes: Optional[Mapping[str, str]] = None,
             instance_id: Optional[str] = None,
             service_id: Optional[str] = None)func NewInstance(ctx *Context, name string, args InstanceArgs, opts ...ResourceOption) (*Instance, error)public Instance(string name, InstanceArgs args, CustomResourceOptions? opts = null)
public Instance(String name, InstanceArgs args)
public Instance(String name, InstanceArgs args, CustomResourceOptions options)
type: aws:servicediscovery:Instance
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args InstanceArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args InstanceArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args InstanceArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args InstanceArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args InstanceArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var exampleinstanceResourceResourceFromServicediscoveryinstance = new Aws.ServiceDiscovery.Instance("exampleinstanceResourceResourceFromServicediscoveryinstance", new()
{
    Attributes = 
    {
        { "string", "string" },
    },
    InstanceId = "string",
    ServiceId = "string",
});
example, err := servicediscovery.NewInstance(ctx, "exampleinstanceResourceResourceFromServicediscoveryinstance", &servicediscovery.InstanceArgs{
	Attributes: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	InstanceId: pulumi.String("string"),
	ServiceId:  pulumi.String("string"),
})
var exampleinstanceResourceResourceFromServicediscoveryinstance = new Instance("exampleinstanceResourceResourceFromServicediscoveryinstance", InstanceArgs.builder()
    .attributes(Map.of("string", "string"))
    .instanceId("string")
    .serviceId("string")
    .build());
exampleinstance_resource_resource_from_servicediscoveryinstance = aws.servicediscovery.Instance("exampleinstanceResourceResourceFromServicediscoveryinstance",
    attributes={
        "string": "string",
    },
    instance_id="string",
    service_id="string")
const exampleinstanceResourceResourceFromServicediscoveryinstance = new aws.servicediscovery.Instance("exampleinstanceResourceResourceFromServicediscoveryinstance", {
    attributes: {
        string: "string",
    },
    instanceId: "string",
    serviceId: "string",
});
type: aws:servicediscovery:Instance
properties:
    attributes:
        string: string
    instanceId: string
    serviceId: string
Instance Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Instance resource accepts the following input properties:
- Attributes Dictionary<string, string>
- A map contains the attributes of the instance. Check the doc for the supported attributes and syntax.
- InstanceId string
- The ID of the service instance.
- ServiceId string
- The ID of the service that you want to use to create the instance.
- Attributes map[string]string
- A map contains the attributes of the instance. Check the doc for the supported attributes and syntax.
- InstanceId string
- The ID of the service instance.
- ServiceId string
- The ID of the service that you want to use to create the instance.
- attributes Map<String,String>
- A map contains the attributes of the instance. Check the doc for the supported attributes and syntax.
- instanceId String
- The ID of the service instance.
- serviceId String
- The ID of the service that you want to use to create the instance.
- attributes {[key: string]: string}
- A map contains the attributes of the instance. Check the doc for the supported attributes and syntax.
- instanceId string
- The ID of the service instance.
- serviceId string
- The ID of the service that you want to use to create the instance.
- attributes Mapping[str, str]
- A map contains the attributes of the instance. Check the doc for the supported attributes and syntax.
- instance_id str
- The ID of the service instance.
- service_id str
- The ID of the service that you want to use to create the instance.
- attributes Map<String>
- A map contains the attributes of the instance. Check the doc for the supported attributes and syntax.
- instanceId String
- The ID of the service instance.
- serviceId String
- The ID of the service that you want to use to create the instance.
Outputs
All input properties are implicitly available as output properties. Additionally, the Instance resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing Instance Resource
Get an existing Instance resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: InstanceState, opts?: CustomResourceOptions): Instance@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        attributes: Optional[Mapping[str, str]] = None,
        instance_id: Optional[str] = None,
        service_id: Optional[str] = None) -> Instancefunc GetInstance(ctx *Context, name string, id IDInput, state *InstanceState, opts ...ResourceOption) (*Instance, error)public static Instance Get(string name, Input<string> id, InstanceState? state, CustomResourceOptions? opts = null)public static Instance get(String name, Output<String> id, InstanceState state, CustomResourceOptions options)resources:  _:    type: aws:servicediscovery:Instance    get:      id: ${id}- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Attributes Dictionary<string, string>
- A map contains the attributes of the instance. Check the doc for the supported attributes and syntax.
- InstanceId string
- The ID of the service instance.
- ServiceId string
- The ID of the service that you want to use to create the instance.
- Attributes map[string]string
- A map contains the attributes of the instance. Check the doc for the supported attributes and syntax.
- InstanceId string
- The ID of the service instance.
- ServiceId string
- The ID of the service that you want to use to create the instance.
- attributes Map<String,String>
- A map contains the attributes of the instance. Check the doc for the supported attributes and syntax.
- instanceId String
- The ID of the service instance.
- serviceId String
- The ID of the service that you want to use to create the instance.
- attributes {[key: string]: string}
- A map contains the attributes of the instance. Check the doc for the supported attributes and syntax.
- instanceId string
- The ID of the service instance.
- serviceId string
- The ID of the service that you want to use to create the instance.
- attributes Mapping[str, str]
- A map contains the attributes of the instance. Check the doc for the supported attributes and syntax.
- instance_id str
- The ID of the service instance.
- service_id str
- The ID of the service that you want to use to create the instance.
- attributes Map<String>
- A map contains the attributes of the instance. Check the doc for the supported attributes and syntax.
- instanceId String
- The ID of the service instance.
- serviceId String
- The ID of the service that you want to use to create the instance.
Import
Using pulumi import, import Service Discovery Instance using the service ID and instance ID. For example:
$ pulumi import aws:servicediscovery/instance:Instance example 0123456789/i-0123
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the awsTerraform Provider.