Skip to content
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

fix(eks): ConfigCommand and GetTokenCommand should output by default #33673

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(eks): ConfigCommand and GetTokenCommand are output by default
  • Loading branch information
wafuwafu13 committed Mar 2, 2025
commit db91ec3f2f7f32d67daf8508484dc106fe5f12f7
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-eks-v2-alpha/lib/cluster.ts
Original file line number Diff line number Diff line change
@@ -1325,7 +1325,7 @@ export class Cluster extends ClusterBase {
this.defineCoreDnsComputeType(CoreDnsComputeType.FARGATE);
}

const outputConfigCommand = (props.outputConfigCommand ?? true) && props.mastersRole;
const outputConfigCommand = (props.outputConfigCommand ?? true);
if (outputConfigCommand) {
const postfix = commonCommandOptions.join(' ');
new CfnOutput(this, 'ConfigCommand', { value: `${updateConfigCommandPrefix} ${postfix}` });
7 changes: 5 additions & 2 deletions packages/@aws-cdk/aws-eks-v2-alpha/test/cluster.test.ts
Original file line number Diff line number Diff line change
@@ -990,7 +990,7 @@ describe('cluster', () => {
});

describe('outputs', () => {
test('no outputs are synthesized by default', () => {
test('ConfigCommand and GetTokenCommand are output by default', () => {
// GIVEN
const { app, stack } = testFixtureNoVpc();

@@ -1000,7 +1000,10 @@ describe('cluster', () => {
// THEN
const assembly = app.synth();
const template = assembly.getStackByName(stack.stackName).template;
expect(template.Outputs).toBeUndefined(); // no outputs
expect(template.Outputs).toEqual({
ClusterConfigCommand43AAE40F: { Value: { 'Fn::Join': ['', ['aws eks update-kubeconfig --name ', { Ref: 'ClusterEB0386A7' }, ' --region us-east-1']] } },
ClusterGetTokenCommand06AE992E: { Value: { 'Fn::Join': ['', ['aws eks get-token --cluster-name ', { Ref: 'ClusterEB0386A7' }, ' --region us-east-1']] } },
});
});

describe('boostrap user-data', () => {
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-eks/lib/cluster.ts
Original file line number Diff line number Diff line change
@@ -1842,7 +1842,7 @@ export class Cluster extends ClusterBase {
this.addNodegroupCapacity('DefaultCapacity', { instanceTypes: [instanceType], minSize: minCapacity }) : undefined;
}

const outputConfigCommand = (props.outputConfigCommand ?? true) && props.mastersRole;
const outputConfigCommand = (props.outputConfigCommand ?? true);
if (outputConfigCommand) {
const postfix = commonCommandOptions.join(' ');
new CfnOutput(this, 'ConfigCommand', { value: `${updateConfigCommandPrefix} ${postfix}` });
9 changes: 6 additions & 3 deletions packages/aws-cdk-lib/aws-eks/test/cluster.test.ts
Original file line number Diff line number Diff line change
@@ -1350,7 +1350,7 @@ describe('cluster', () => {
});

describe('outputs', () => {
test('no outputs are synthesized by default', () => {
test('ConfigCommand and GetTokenCommand are output by default', () => {
// GIVEN
const { app, stack } = testFixtureNoVpc();

@@ -1360,7 +1360,10 @@ describe('cluster', () => {
// THEN
const assembly = app.synth();
const template = assembly.getStackByName(stack.stackName).template;
expect(template.Outputs).toBeUndefined(); // no outputs
expect(template.Outputs).toEqual({
ClusterConfigCommand43AAE40F: { Value: { 'Fn::Join': ['', ['aws eks update-kubeconfig --name ', { Ref: 'Cluster9EE0221C' }, ' --region us-east-1']] } },
ClusterGetTokenCommand06AE992E: { Value: { 'Fn::Join': ['', ['aws eks get-token --cluster-name ', { Ref: 'Cluster9EE0221C' }, ' --region us-east-1']] } },
});
});

test('if masters role is defined, it should be included in the config command', () => {
@@ -1385,7 +1388,7 @@ describe('cluster', () => {
});
});

test('if `outputConfigCommand=false` will disabled the output', () => {
test('outputConfigCommand=false` will disabled the output of ConfigCommand and GetTokenCommand', () => {
// GIVEN
const { app, stack } = testFixtureNoVpc();

Loading
Oops, something went wrong.