The CDK Construct Library for AWS::ServiceDiscovery
Project description
Amazon ECS Service Discovery Construct Library
This is a developer preview (public beta) module. Releases might lack important features and might have future breaking changes.
This module is part of the AWS Cloud Development Kit project.
This package contains constructs for working with AWS Cloud Map
AWS Cloud Map is a fully managed service that you can use to create and maintain a map of the backend services and resources that your applications depend on.
For further information on AWS Cloud Map, see the AWS Cloud Map documentation
The following example creates an AWS Cloud Map namespace that supports API calls, creates a service in that namespace, and registers an instance to it:
import cdk = require('@aws-cdk/core');
import servicediscovery = require('../lib');
const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-servicediscovery-integ');
const namespace = new servicediscovery.HttpNamespace(stack, 'MyNamespace', {
name: 'covfefe',
});
const service1 = namespace.createService('NonIpService', {
description: 'service registering non-ip instances',
});
service1.registerNonIpInstance('NonIpInstance', {
customAttributes: { arn: 'arn:aws:s3:::mybucket' }
});
const service2 = namespace.createService('IpService', {
description: 'service registering ip instances',
healthCheck: {
type: servicediscovery.HealthCheckType.HTTP,
resourcePath: '/check'
}
});
service2.registerIpInstance('IpInstance', {
ipv4: '54.239.25.192',
});
app.synth();
The following example creates an AWS Cloud Map namespace that supports both API calls and DNS queries within a vpc, creates a service in that namespace, and registers a loadbalancer as an instance:
import ec2 = require('@aws-cdk/aws-ec2');
import elbv2 = require('@aws-cdk/aws-elasticloadbalancingv2');
import cdk = require('@aws-cdk/core');
import servicediscovery = require('../lib');
const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-servicediscovery-integ');
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAZs: 2 });
const namespace = new servicediscovery.PrivateDnsNamespace(stack, 'Namespace', {
name: 'boobar.com',
vpc,
});
const service = namespace.createService('Service', {
dnsRecordType: servicediscovery.DnsRecordType.A_AAAA,
dnsTtl: cdk.Duration.seconds(30),
loadBalancer: true
});
const loadbalancer = new elbv2.ApplicationLoadBalancer(stack, 'LB', { vpc, internetFacing: true });
service.registerLoadBalancer("Loadbalancer", loadbalancer);
app.synth();
The following example creates an AWS Cloud Map namespace that supports both API calls and public DNS queries, creates a service in that namespace, and registers an IP instance:
import cdk = require('@aws-cdk/core');
import servicediscovery = require('../lib');
const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-servicediscovery-integ');
const namespace = new servicediscovery.PublicDnsNamespace(stack, 'Namespace', {
name: 'foobar.com',
});
const service = namespace.createService('Service', {
name: 'foo',
dnsRecordType: servicediscovery.DnsRecordType.A,
dnsTtl: cdk.Duration.seconds(30),
healthCheck: {
type: servicediscovery.HealthCheckType.HTTPS,
resourcePath: '/healthcheck',
failureThreshold: 2
}
});
service.registerIpInstance('IpInstance', {
ipv4: '54.239.25.192',
port: 443
});
app.synth();
For DNS namespaces, you can also register instances to services with CNAME records:
import cdk = require('@aws-cdk/core');
import servicediscovery = require('../lib');
const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-servicediscovery-integ');
const namespace = new servicediscovery.PublicDnsNamespace(stack, 'Namespace', {
name: 'foobar.com',
});
const service = namespace.createService('Service', {
name: 'foo',
dnsRecordType: servicediscovery.DnsRecordType.CNAME,
dnsTtl: cdk.Duration.seconds(30)
});
service.registerCnameInstance('CnameInstance', {
instanceCname: 'service.pizza',
});
app.synth();
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for aws-cdk.aws-servicediscovery-0.36.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f8ec5315b7e328e140bd57eb8b105485976a8f34ac51c13c089314051098506 |
|
MD5 | 912813852915f7a12d164c5ac3eb2b4a |
|
BLAKE2b-256 | 5064b711cd1f5002a9164bd794c11ae8d68368c7043f8c3abb7c4a148721e3a4 |
Hashes for aws_cdk.aws_servicediscovery-0.36.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58014e07d7faf6c3277c8e72e7ce5115a4e68c37375c339430c44e4493f68542 |
|
MD5 | 441937b734d9d7dabf7350f3a440507a |
|
BLAKE2b-256 | d4fcdeaaff4d984ddfc7ae32c4ed745ecfa8c5ef913256435fe7dc9d588e45fd |