forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
582 additions
and
2 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
packages/@aws-cdk/aws-servicediscovery/lib/http-namespace.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import cdk = require('@aws-cdk/cdk'); | ||
import { CfnHttpNamespace } from './servicediscovery.generated'; | ||
|
||
export interface HttpNamespaceProps { | ||
/** | ||
* A name for the HttpNamespace. | ||
*/ | ||
name: string; | ||
|
||
/** | ||
* A description of the namespace. | ||
*/ | ||
description?: string; | ||
} | ||
|
||
/** | ||
* Define a Service Discovery HTTP Namespace | ||
*/ | ||
export class HttpNamespace extends cdk.Construct { | ||
/** | ||
* A domain name | ||
*/ | ||
public readonly name: string; | ||
|
||
/** | ||
* Namespace Id for the HttpNamespace. | ||
*/ | ||
public readonly namespaceId: string; | ||
|
||
constructor(scope: cdk.Construct, id: string, props: HttpNamespaceProps) { | ||
super(scope, id); | ||
|
||
const ns = new CfnHttpNamespace(this, 'Resource', { | ||
name: props.name, | ||
description: props.description | ||
}); | ||
|
||
this.name = props.name; | ||
this.namespaceId = ns.httpNamespaceId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
export * from './http-namespace'; | ||
export * from './private-dns-namespace'; | ||
export * from './public-dns-namespace'; | ||
export * from './instance'; | ||
export * from './service'; | ||
// AWS::ServiceDiscovery CloudFormation Resources: | ||
export * from './servicediscovery.generated'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import cdk = require('@aws-cdk/cdk'); | ||
import { CfnInstance } from './servicediscovery.generated'; | ||
|
||
/** | ||
* Properties to define ServiceDiscovery Instance | ||
*/ | ||
export interface InstanceProps { | ||
// TODO set defaults so not all required? | ||
instanceAttributes: InstanceAttributes | ||
|
||
instanceId: string; | ||
|
||
serviceId: string; | ||
} | ||
|
||
/** | ||
* Define a Service Discovery Instance | ||
*/ | ||
export class Instance extends cdk.Construct { | ||
public readonly instanceAttributes: InstanceAttributes; | ||
/** | ||
* The Id of the instance | ||
*/ | ||
public readonly instanceId: string; | ||
/** | ||
* The Cloudmap service to which the instance is registered. | ||
*/ | ||
public readonly serviceId: string; | ||
|
||
constructor(scope: cdk.Construct, id: string, props: InstanceProps) { | ||
super(scope, id); | ||
|
||
new CfnInstance(this, 'Resource', { | ||
instanceAttributes: props.instanceAttributes, | ||
instanceId: props.instanceId, | ||
serviceId: props.serviceId | ||
}); | ||
} | ||
} | ||
|
||
export interface InstanceAttributes { | ||
/** | ||
* If you want AWS Cloud Map to create an Amazon Route 53 alias record that routes traffic to an Elastic Load | ||
* Balancing load balancer, specify the DNS name that is associated with the load balancer. | ||
*/ | ||
aliasDnsName?: string, | ||
|
||
/** | ||
* If the service configuration includes a CNAME record, the domain name that you want Route 53 to return in | ||
* response to DNS queries, for example, example.com. This value is required if the service specified by ServiceId | ||
* includes settings for an CNAME record. | ||
*/ | ||
instanceCName?: string, | ||
|
||
/** The port on the endpoint that you want AWS Cloud Map to perform health checks on. This value is also used for | ||
* the port value in an SRV record if the service that you specify includes an SRV record. You can also specify a | ||
* default port that is applied to all instances in the Service configuration. | ||
*/ | ||
instancePort?: string, | ||
/** | ||
* If the service that you specify contains a template for an A record, the IPv4 address that you want AWS Cloud | ||
* Map to use for the value of the A record. | ||
*/ | ||
instanceIpv4?: string, | ||
/** | ||
* If the service that you specify contains a template for an AAAA record, the IPv6 address that you want AWS Cloud | ||
* Map to use for the value of the AAAA record. | ||
*/ | ||
instanceIpv6?: string, | ||
} |
145 changes: 145 additions & 0 deletions
145
packages/@aws-cdk/aws-servicediscovery/lib/namespace.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import ec2 = require('@aws-cdk/aws-ec2'); | ||
import cdk = require('@aws-cdk/cdk'); | ||
import { CfnHttpNamespace, CfnPrivateDnsNamespace, CfnPublicDnsNamespace} from './servicediscovery.generated'; | ||
|
||
export interface INamespace extends cdk.IConstruct { | ||
/** | ||
* A name for the Namespace. | ||
*/ | ||
readonly name: string; | ||
|
||
/** | ||
* Namespace Id for the Namespace. | ||
*/ | ||
readonly namespaceId: string; | ||
|
||
/** | ||
* Namespace ARN for the Namespace. | ||
*/ | ||
readonly namespaceArn: string; | ||
|
||
/** | ||
* Type of Namespace. Valid values: HTTP, DNS_PUBLIC, or DNS_PRIVATE | ||
*/ | ||
readonly type: NamespaceType; | ||
} | ||
|
||
export interface NamespaceProps { | ||
/** | ||
* A name for the Namespace. | ||
*/ | ||
name: string; | ||
|
||
/** | ||
* A description of the Namespace. | ||
* | ||
* @default none | ||
*/ | ||
description?: string; | ||
|
||
/** | ||
* Type of Namespace. Valid values: HTTP, DNS_PUBLIC, or DNS_PRIVATE | ||
* | ||
* @default HTTP | ||
*/ | ||
type?: NamespaceType; | ||
|
||
/** | ||
* The Amazon VPC that you want to associate the namespace with. | ||
* Only applies for Private DNS Namespaces. | ||
* | ||
* @default none | ||
*/ | ||
vpc?: ec2.IVpcNetwork; | ||
|
||
} | ||
|
||
export interface NamespaceImportProps { | ||
/** | ||
* A name for the Namespace. | ||
*/ | ||
readonly name: string; | ||
|
||
/** | ||
* Namespace Id for the Namespace. | ||
*/ | ||
readonly namespaceId: string; | ||
|
||
/** | ||
* Namespace ARN for the Namespace. | ||
*/ | ||
readonly namespaceArn: string; | ||
|
||
/** | ||
* Type of Namespace. Valid values: HTTP, DNS_PUBLIC, or DNS_PRIVATE | ||
*/ | ||
readonly type: NamespaceType; | ||
} | ||
|
||
export enum NamespaceType { | ||
Http = "HTTP", | ||
DnsPublic = "DNS_PUBLIC", | ||
DnsPrivate = "DNS_PRIVATE" | ||
} | ||
|
||
export class Namespace extends cdk.Construct implements INamespace { | ||
public readonly name: string; | ||
public readonly namespaceId: string; | ||
public readonly namespaceArn: string; | ||
public readonly type: NamespaceType; | ||
|
||
constructor(scope: cdk.Construct, id: string, props: NamespaceProps) { | ||
super(scope, id); | ||
|
||
const name = props.name; | ||
const description = props.description; | ||
|
||
let namespaceType = props.type; | ||
if (namespaceType === undefined) { | ||
namespaceType = NamespaceType.Http; | ||
} | ||
|
||
this.name = name; | ||
this.type = namespaceType; | ||
|
||
switch (namespaceType) { | ||
case NamespaceType.Http: { | ||
const ns = new CfnHttpNamespace(this, 'Resource', { | ||
name, | ||
description | ||
}); | ||
|
||
this.namespaceId = ns.httpNamespaceId; | ||
this.namespaceArn = ns.httpNamespaceArn; | ||
break; | ||
} | ||
|
||
case NamespaceType.DnsPrivate: { | ||
if (props.vpc === undefined) { | ||
throw new Error(`VPC must be specified for PrivateDNSNamespaces`); | ||
} | ||
|
||
const ns = new CfnPrivateDnsNamespace(this, 'Resource', { | ||
name, | ||
description, | ||
vpc: props.vpc.vpcId | ||
}); | ||
|
||
this.namespaceId = ns.privateDnsNamespaceId; | ||
this.namespaceArn = ns.privateDnsNamespaceArn; | ||
break; | ||
} | ||
|
||
case NamespaceType.DnsPublic: { | ||
const ns = new CfnPublicDnsNamespace(this, 'Resource', { | ||
name, | ||
description | ||
}); | ||
|
||
this.namespaceId = ns.publicDnsNamespaceId; | ||
this.namespaceArn = ns.publicDnsNamespaceArn; | ||
break; | ||
} | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
packages/@aws-cdk/aws-servicediscovery/lib/private-dns-namespace.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import ec2 = require('@aws-cdk/aws-ec2'); | ||
import cdk = require('@aws-cdk/cdk'); | ||
import { CfnPrivateDnsNamespace} from './servicediscovery.generated'; | ||
|
||
export interface PrivateDnsNamespaceProps { | ||
/** | ||
* A name for the HttpNamespace. | ||
*/ | ||
name: string; | ||
|
||
/** | ||
* The Amazon VPC that you want to associate the namespace with. | ||
*/ | ||
vpc: ec2.IVpcNetwork; | ||
|
||
/** | ||
* A description of the namespace. | ||
*/ | ||
description?: string; | ||
} | ||
|
||
/** | ||
* Define a Service Discovery HTTP Namespace | ||
*/ | ||
export class PrivateDnsNamespace extends cdk.Construct { | ||
/** | ||
* A name for the PrivateDnsNamespace. | ||
*/ | ||
public readonly name: string; | ||
|
||
/** | ||
* Namespace Id for the PrivateDnsNamespace. | ||
*/ | ||
public readonly namespaceId: string; | ||
|
||
/** | ||
* The Amazon VPC that you want to associate the namespace with. | ||
*/ | ||
public readonly vpc: ec2.IVpcNetwork; | ||
|
||
constructor(scope: cdk.Construct, id: string, props: PrivateDnsNamespaceProps) { | ||
super(scope, id); | ||
|
||
const ns = new CfnPrivateDnsNamespace(this, 'Resource', { | ||
name: props.name, | ||
description: props.description, | ||
vpc: props.vpc.vpcId | ||
}); | ||
|
||
this.vpc = props.vpc; | ||
this.name = props.name; | ||
this.namespaceId = ns.privateDnsNamespaceId; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
packages/@aws-cdk/aws-servicediscovery/lib/public-dns-namespace.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import cdk = require('@aws-cdk/cdk'); | ||
import { CfnPublicDnsNamespace} from './servicediscovery.generated'; | ||
|
||
export interface PublicDnsNamespaceProps { | ||
/** | ||
* A name for the HttpNamespace. | ||
*/ | ||
name: string; | ||
|
||
/** | ||
* A description of the namespace. | ||
*/ | ||
description?: string; | ||
} | ||
|
||
/** | ||
* Define a Service Discovery HTTP Namespace | ||
*/ | ||
export class PublicDnsNamespace extends cdk.Construct { | ||
/** | ||
* A name for the PublicDnsNamespace. | ||
*/ | ||
public readonly name: string; | ||
|
||
/** | ||
* Namespace Id for the PublicDnsNamespace. | ||
*/ | ||
public readonly namespaceId: string; | ||
|
||
constructor(scope: cdk.Construct, id: string, props: PublicDnsNamespaceProps) { | ||
super(scope, id); | ||
|
||
const ns = new CfnPublicDnsNamespace(this, 'Resource', { | ||
name: props.name, | ||
description: props.description, | ||
}); | ||
|
||
this.name = props.name; | ||
this.namespaceId = ns.publicDnsNamespaceId; | ||
} | ||
} |
Oops, something went wrong.