Skip to content

Commit

Permalink
expose eks cluster additional attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardomourar committed May 27, 2020
1 parent 22cfab8 commit a1e707d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ export class ClusterResourceHandler extends ResourceHandler {
Endpoint: cluster.endpoint,
Arn: cluster.arn,
CertificateAuthorityData: cluster.certificateAuthority?.data,
ClusterSecurityGroupId: cluster.resourcesVpcConfig?.clusterSecurityGroupId,
EncryptionConfigKeyArn: cluster.encryptionConfig?.shift()?.provider?.keyArn,
OpenIdConnectIssuerUrl: cluster.identity?.oidc?.issuer,
OpenIdConnectIssuer: cluster.identity?.oidc?.issuer?.substring(8), // Strips off https:// from the issuer url
},
Expand Down
4 changes: 4 additions & 0 deletions packages/@aws-cdk/aws-eks/lib/cluster-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export class ClusterResource extends Construct {
public readonly attrEndpoint: string;
public readonly attrArn: string;
public readonly attrCertificateAuthorityData: string;
public readonly attrClusterSecurityGroupId: string;
public readonly attrEncryptionConfigKeyArn: string;
public readonly attrOpenIdConnectIssuerUrl: string;
public readonly attrOpenIdConnectIssuer: string;
public readonly ref: string;
Expand Down Expand Up @@ -126,6 +128,8 @@ export class ClusterResource extends Construct {
this.attrEndpoint = Token.asString(resource.getAtt('Endpoint'));
this.attrArn = Token.asString(resource.getAtt('Arn'));
this.attrCertificateAuthorityData = Token.asString(resource.getAtt('CertificateAuthorityData'));
this.attrClusterSecurityGroupId = Token.asString(resource.getAtt('ClusterSecurityGroupId'));
this.attrEncryptionConfigKeyArn = Token.asString(resource.getAtt('EncryptionConfigKeyArn'));
this.attrOpenIdConnectIssuerUrl = Token.asString(resource.getAtt('OpenIdConnectIssuerUrl'));
this.attrOpenIdConnectIssuer = Token.asString(resource.getAtt('OpenIdConnectIssuer'));
}
Expand Down
38 changes: 38 additions & 0 deletions packages/@aws-cdk/aws-eks/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ export interface ICluster extends IResource, ec2.IConnectable {
* @attribute
*/
readonly clusterCertificateAuthorityData: string;

/**
* The cluster security group that was created by Amazon EKS for the cluster.
* @attribute
*/
readonly clusterSecurityGroupId: string;

/**
* Amazon Resource Name (ARN) or alias of the customer master key (CMK).
* @attribute
*/
readonly clusterEncryptionConfigKeyArn: string;
}

/**
Expand Down Expand Up @@ -84,6 +96,16 @@ export interface ClusterAttributes {
*/
readonly clusterCertificateAuthorityData: string;

/**
* The cluster security group that was created by Amazon EKS for the cluster.
*/
readonly clusterSecurityGroupId: string;

/**
* Amazon Resource Name (ARN) or alias of the customer master key (CMK).
*/
readonly clusterEncryptionConfigKeyArn: string;

/**
* The security groups associated with this cluster.
*/
Expand Down Expand Up @@ -299,6 +321,16 @@ export class Cluster extends Resource implements ICluster {
*/
public readonly clusterCertificateAuthorityData: string;

/**
* The cluster security group that was created by Amazon EKS for the cluster.
*/
public readonly clusterSecurityGroupId: string;

/**
* Amazon Resource Name (ARN) or alias of the customer master key (CMK).
*/
public readonly clusterEncryptionConfigKeyArn: string;

/**
* Manages connection rules (Security Group Rules) for the cluster
*
Expand Down Expand Up @@ -414,6 +446,8 @@ export class Cluster extends Resource implements ICluster {

this.clusterEndpoint = resource.attrEndpoint;
this.clusterCertificateAuthorityData = resource.attrCertificateAuthorityData;
this.clusterSecurityGroupId = resource.attrClusterSecurityGroupId;
this.clusterEncryptionConfigKeyArn = resource.attrEncryptionConfigKeyArn;

const updateConfigCommandPrefix = `aws eks update-kubeconfig --name ${this.clusterName}`;
const getTokenCommandPrefix = `aws eks get-token --cluster-name ${this.clusterName}`;
Expand Down Expand Up @@ -990,6 +1024,8 @@ export interface AutoScalingGroupOptions {
class ImportedCluster extends Resource implements ICluster {
public readonly vpc: ec2.IVpc;
public readonly clusterCertificateAuthorityData: string;
public readonly clusterSecurityGroupId: string;
public readonly clusterEncryptionConfigKeyArn: string;
public readonly clusterName: string;
public readonly clusterArn: string;
public readonly clusterEndpoint: string;
Expand All @@ -1003,6 +1039,8 @@ class ImportedCluster extends Resource implements ICluster {
this.clusterEndpoint = props.clusterEndpoint;
this.clusterArn = props.clusterArn;
this.clusterCertificateAuthorityData = props.clusterCertificateAuthorityData;
this.clusterSecurityGroupId = props.clusterSecurityGroupId;
this.clusterEncryptionConfigKeyArn = props.clusterEncryptionConfigKeyArn;

let i = 1;
for (const sgProps of props.securityGroups) {
Expand Down
8 changes: 1 addition & 7 deletions packages/@aws-cdk/aws-eks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,7 @@
},
"awslint": {
"exclude": [
"resource-attribute:@aws-cdk/aws-eks.FargateCluster.clusterSecurityGroupId",
"resource-attribute:@aws-cdk/aws-eks.FargateCluster.clusterEncryptionConfigKeyArn",
"resource-attribute:@aws-cdk/aws-eks.Cluster.clusterSecurityGroupId",
"resource-attribute:@aws-cdk/aws-eks.Cluster.clusterEncryptionConfigKeyArn",
"props-no-arn-refs:@aws-cdk/aws-eks.ClusterProps.outputMastersRoleArn",
"resource-attribute:@aws-cdk/aws-eks.Cluster.clusterSecurityGroupId",
"resource-attribute:@aws-cdk/aws-eks.Cluster.clusterSecurityGroupId"
"props-no-arn-refs:@aws-cdk/aws-eks.ClusterProps.outputMastersRoleArn"
]
},
"stability": "experimental",
Expand Down

0 comments on commit a1e707d

Please sign in to comment.