-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP feat(ecs): Enable Cloudmap Service Discovery #4
Conversation
*/ | ||
public addNamespace(name: string): cloudmap.PrivateDnsNamespace { | ||
const sdNamespace = new cloudmap.PrivateDnsNamespace(this, 'DefaultServiceDiscoveryNamespace', { | ||
name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to have this autogenerated?
Does it make sense to default it to some particular value that we can derive from another value?
Does it make sense to add a boolean to the constructor props to call this automatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have name generated? No, that is usually the one thing customers would want to specify -- it's the domain name, so like foo.com
not sure what you mean by the boolean in the constructor props?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking:
class ClusterProps {
// ...
/**
* Domain name for the private DNS namespace to create
*
* @default No namespace is created by default
*/
privateDnsNamespaceDomainName?: string
}
Which would imply a call to addNamespace
.
But looking at this, I do have a couple more questions:
- Would you ever have more than one namespace? (Right now you can't call this more than once)
- Would it always be a private namespace? (Right now doesn't look like you could do a public or HTTP namespace even if you wanted to)
- Is
cluster.addNamespace()
descriptive enough? (Maybecluster.addCloudMapNamespace()?
).
/** | ||
* Enable CloudMap service discovery for the service | ||
*/ | ||
public enableServiceDiscovery(props: ServiceDiscoveryProps): cloudmap.Service { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does use of this method require that the Cluster has addNamespace()
called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does, but since addNamespace()
adds the namespaceId (or namespace as a member) on the cluster we can check the value there, if you're concerned about validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am, please do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, I think we're standardizing on FooOptions
for arguments to a method (FooProps
is for arguments to a constructor)
/** | ||
* Define a Service Discovery HTTP Namespace | ||
*/ | ||
export class PrivateDnsNamespace extends cdk.Construct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there are more generic INamespace
interface to be extracted between HttpNamespace
and PrivateDnsNamespace
, or does that not make sense?
const ns = new CfnPrivateDnsNamespace(this, 'Resource', { | ||
name: props.name, | ||
description: props.description, | ||
vpc: props.vpc.vpcId // NOTE: not sure this is right |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is.
/** | ||
* The ID of the namespace that you want to use for DNS configuration. | ||
*/ | ||
namespaceId: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like you should want to pass in an INamespace
here.
0238252
to
1a766b5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My big question is: why do we register a namespace on a Cluster
at all? Seems like supplying an INamespace
to a Service
should be enough, no?
/** | ||
* Enable CloudMap service discovery for the service | ||
*/ | ||
public enableServiceDiscovery(props: ServiceDiscoveryProps): cloudmap.Service { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am, please do.
/** | ||
* Enable CloudMap service discovery for the service | ||
*/ | ||
public enableServiceDiscovery(props: ServiceDiscoveryProps): cloudmap.Service { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, I think we're standardizing on FooOptions
for arguments to a method (FooProps
is for arguments to a constructor)
} | ||
|
||
const cloudmapService = new cloudmap.Service(this, 'CloudmapService', { | ||
namespaceId: props.namespaceId, // FIXME use INamespace instead -- validate if cluster has called addNamespace set? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you not taking the namespaceId
from the cluster in any case? It's there, why make the user pass it in again? And in case there can be multiple namespaces why store it on the cluster at all?
Why does cluster.addNamespace()
exist, anyway?
// add Cloudmap service to the ECS Service's serviceRegistry | ||
this.serviceRegistries.push({ | ||
registryArn: serviceArn, | ||
containerName: this.taskDefinition.defaultContainer!.node.id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for existence of a default container. It might not exist if addContainer()
hasn't been called yet.
* The DNS type of the record that you want AWS Cloud Map to create. Supported record types | ||
* include A, AAAA, A_AAAA, CNAME, and SRV. | ||
*/ | ||
dnsType: DnsRecordType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if namespace is of HTTP type? Does that still have a dnsType
?
{ | ||
dnsRecords: [ | ||
{ | ||
type: dnsType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate that dnsType is set when you make it optioanl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, namespaceId (and routingPolicy) also both seem to not be set in case of an HTTP namespace.
How can this work?
|
||
export interface DnsConfig { | ||
dnsRecords: DnsRecord[], | ||
namespaceId: string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really a nice interface to export
. If it's a reference to some other resource, we don't reference it by string-id by by interface (INamespace
here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I was only using it to make it easier in the constructor (line 97), but perhaps exporting the interface this way isn't the way to go?
/** | ||
* The time to live for the record | ||
*/ | ||
ttl: string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ttlSec
. WHy is it a string
and not a number
?
f65e6ee
to
3ac3e0d
Compare
a5ee563
to
314f75a
Compare
fix public DNS namespace
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.