diff --git a/.github/workflows/run-integ-tests.yaml b/.github/workflows/run-integ-tests.yaml index 63961a2a4..34953825a 100644 --- a/.github/workflows/run-integ-tests.yaml +++ b/.github/workflows/run-integ-tests.yaml @@ -123,9 +123,6 @@ jobs: - # issue #49 app_to_test: ts-eks-helm mode: upgrade - - # issue #49 - app_to_test: ts-eks-helm - mode: fresh steps: - uses: actions/checkout@v3 with: diff --git a/pkg/infra/pulumi_aws/deploylib.ts b/pkg/infra/pulumi_aws/deploylib.ts index ceaa73d6e..e4aa906d2 100755 --- a/pkg/infra/pulumi_aws/deploylib.ts +++ b/pkg/infra/pulumi_aws/deploylib.ts @@ -100,7 +100,7 @@ export class CloudCCLib { private sharedRepo: awsx.ecr.Repository, private stage: string, private region: Region, - private name: string, + public readonly name: string, private namespace: string, private datadogEnabled: boolean, physicalPayloadsBucketName: string, diff --git a/pkg/infra/pulumi_aws/iac/eks.ts b/pkg/infra/pulumi_aws/iac/eks.ts index 50905efb5..426a36dd3 100644 --- a/pkg/infra/pulumi_aws/iac/eks.ts +++ b/pkg/infra/pulumi_aws/iac/eks.ts @@ -576,12 +576,12 @@ export class Eks { }) if (needsGatewayLink) { - const lb = lib.lbPlugin.createLoadBalancer(execUnit, { + const lb = lib.lbPlugin.createLoadBalancer(lib.name, execUnit, { subnets: lib.privateSubnetIds, loadBalancerType: 'network', }) - const targetGroup = lib.lbPlugin.createTargetGroup(execUnit, { + const targetGroup = lib.lbPlugin.createTargetGroup(lib.name, execUnit, { port: 3000, protocol: 'TCP', vpcId: lib.klothoVPC.id, @@ -589,7 +589,7 @@ export class Eks { }) this.execUnitToTargetGroupArn.set(execUnit, targetGroup.arn) - lib.lbPlugin.createListener(execUnit, { + lib.lbPlugin.createListener(lib.name, execUnit, { port: 80, protocol: 'TCP', loadBalancerArn: lb.arn, @@ -633,16 +633,21 @@ export class Eks { const config = new pulumi.Config('aws') const profile = config.get('profile') - let args = ['eks', 'get-token', '--cluster-name', this.cluster.name, '--profile', profile] - const env: ExecEnvVar[] = [ - { - name: 'KUBERNETES_EXEC_INFO', - value: `{"apiVersion": "client.authentication.k8s.io/v1beta1"}`, - }, + let args = [ + 'eks', + 'get-token', + '--cluster-name', + this.cluster.name, + '--region', + this.region, ] + if (profile) { + args.push('--profile', profile) + } + console.log(profile) return pulumi - .all([args, env, this.cluster.endpoint, this.cluster.certificateAuthorities[0].data]) - .apply(([tokenArgs, envvars, clusterEndpoint, certData]) => { + .all([args, this.cluster.endpoint, this.cluster.certificateAuthorities[0].data]) + .apply(([tokenArgs, clusterEndpoint, certData]) => { return { apiVersion: 'v1', clusters: [ @@ -673,7 +678,6 @@ export class Eks { apiVersion: 'client.authentication.k8s.io/v1beta1', command: 'aws', args: tokenArgs, - env: envvars, }, }, }, diff --git a/pkg/infra/pulumi_aws/iac/load_balancing.ts b/pkg/infra/pulumi_aws/iac/load_balancing.ts index 60c3943c0..e3c204f79 100644 --- a/pkg/infra/pulumi_aws/iac/load_balancing.ts +++ b/pkg/infra/pulumi_aws/iac/load_balancing.ts @@ -27,14 +27,15 @@ export class LoadBalancerPlugin { } public createLoadBalancer = ( + appName: string, resourceId: string, params: LoadBalancerArgs ): aws.lb.LoadBalancer => { let lb: aws.lb.LoadBalancer switch (params.loadBalancerType) { case 'application': - lb = new aws.lb.LoadBalancer(`${resourceId}-alb`, { - name: `${resourceId}-alb`, + lb = new aws.lb.LoadBalancer(`${appName}-${resourceId}-alb`, { + name: `${appName}-${resourceId}`, internal: params.internal || false, loadBalancerType: 'application', securityGroups: params.securityGroups, @@ -44,8 +45,8 @@ export class LoadBalancerPlugin { }) break case 'network': - lb = new aws.lb.LoadBalancer(`${resourceId}-nlb`, { - name: `${resourceId}-nlb`, + lb = new aws.lb.LoadBalancer(`${appName}-${resourceId}-nlb`, { + name: `${appName}-${resourceId}`, internal: params.internal || true, loadBalancerType: 'network', subnets: params.subnets, @@ -60,8 +61,12 @@ export class LoadBalancerPlugin { return lb } - public createListener = (resourceId: string, params: ListenerArgs): aws.lb.Listener => { - return new aws.lb.Listener(`${resourceId}-listener`, { + public createListener = ( + appName: string, + resourceId: string, + params: ListenerArgs + ): aws.lb.Listener => { + return new aws.lb.Listener(`${appName}-${resourceId}-listener`, { loadBalancerArn: params.loadBalancerArn, defaultActions: params.defaultActions, port: params.port, @@ -70,10 +75,11 @@ export class LoadBalancerPlugin { } public createListenerRule = ( + appName: string, resourceId: string, params: ListenerRuleArgs ): aws.lb.ListenerRule => { - return new aws.lb.ListenerRule(`${resourceId}-listenerRule`, { + return new aws.lb.ListenerRule(`${appName}-${resourceId}-listenerRule`, { listenerArn: params.listenerArn, actions: params.actions, conditions: params.conditions, @@ -81,15 +87,19 @@ export class LoadBalancerPlugin { }) } - public createTargetGroup = (resourceId, params: TargetGroupArgs): aws.lb.TargetGroup => { + public createTargetGroup = ( + appName: string, + resourceId, + params: TargetGroupArgs + ): aws.lb.TargetGroup => { let targetGroup: aws.lb.TargetGroup if (params.targetType != 'lambda' && !(params.port && params.protocol)) { throw new Error('Port and Protocol must be specified for non lambda target types') } switch (params.targetType) { case 'ip': - targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, { - name: `${resourceId}-targetGroup`, + targetGroup = new aws.lb.TargetGroup(`${appName}-${resourceId}-targetGroup`, { + name: `${appName}-${resourceId}`, port: params.port, protocol: params.protocol, targetType: 'ip', @@ -98,8 +108,8 @@ export class LoadBalancerPlugin { }) break case 'instance': - targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, { - name: `${resourceId}-targetGroup`, + targetGroup = new aws.lb.TargetGroup(`${appName}-${resourceId}-targetGroup`, { + name: `${appName}-${resourceId}`, port: params.port, protocol: params.protocol, vpcId: params.vpcId, @@ -107,8 +117,8 @@ export class LoadBalancerPlugin { }) break case 'alb': - targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, { - name: `${resourceId}-targetGroup`, + targetGroup = new aws.lb.TargetGroup(`${appName}-${resourceId}-targetGroup`, { + name: `${appName}-${resourceId}`, targetType: 'alb', port: params.port, protocol: params.protocol, @@ -118,8 +128,8 @@ export class LoadBalancerPlugin { }) break case 'lambda': - targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, { - name: `${resourceId}-targetGroup`, + targetGroup = new aws.lb.TargetGroup(`${appName}-${resourceId}-targetGroup`, { + name: `${appName}-${resourceId}`, targetType: 'lambda', tags: params.tags, }) @@ -131,10 +141,11 @@ export class LoadBalancerPlugin { } public attachTargetGroupToResource = ( + appName: string, resourceId: string, params: TargetGroupAttachmentArgs ): aws.lb.TargetGroupAttachment => { - return new aws.lb.TargetGroupAttachment(`${resourceId}-targetGroupAttachment`, { + return new aws.lb.TargetGroupAttachment(`${appName}-${resourceId}-targetGroupAttachment`, { targetGroupArn: params.targetGroupArn, targetId: params.targetId, port: params.port,