Skip to content

Commit

Permalink
Merge branch 'main' into 28462-aws-events-match-wildcard
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Dec 5, 2024
2 parents 34ca646 + 8189c82 commit e745df0
Show file tree
Hide file tree
Showing 134 changed files with 5,140 additions and 1,428 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export const CLUSTER_RESOURCE_TYPE = 'Custom::AWSCDK-EKS-Cluster';
export const FARGATE_PROFILE_RESOURCE_TYPE = 'Custom::AWSCDK-EKS-FargateProfile';

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { ProxyAgent } from 'proxy-agent';
import { ClusterResourceHandler } from './cluster';
import { EksClient } from './common';
import * as consts from './consts';
import { FargateProfileResourceHandler } from './fargate';
import { IsCompleteResponse } from 'aws-cdk-lib/custom-resources/lib/provider-framework/types';

const proxyAgent = new ProxyAgent();
Expand Down Expand Up @@ -67,7 +66,6 @@ export async function isComplete(event: AWSLambda.CloudFormationCustomResourceEv
function createResourceHandler(event: AWSLambda.CloudFormationCustomResourceEvent) {
switch (event.ResourceType) {
case consts.CLUSTER_RESOURCE_TYPE: return new ClusterResourceHandler(defaultEksClient, event);
case consts.FARGATE_PROFILE_RESOURCE_TYPE: return new FargateProfileResourceHandler(defaultEksClient, event);
default:
throw new Error(`Unsupported resource type "${event.ResourceType}`);
}
Expand Down
38 changes: 16 additions & 22 deletions packages/@aws-cdk/aws-eks-v2-alpha/lib/fargate-profile.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Construct } from 'constructs';
import { Cluster, AuthenticationMode } from './cluster';
import { FARGATE_PROFILE_RESOURCE_TYPE } from './cluster-resource-handler/consts';
import { ClusterResourceProvider } from './cluster-resource-provider';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as iam from 'aws-cdk-lib/aws-iam';
import { Annotations, CustomResource, ITaggable, Lazy, TagManager, TagType } from 'aws-cdk-lib/core';
import { CfnFargateProfile } from 'aws-cdk-lib/aws-eks';
import { Annotations, ITaggable, TagManager, TagType } from 'aws-cdk-lib/core';

/**
* Options for defining EKS Fargate Profiles.
Expand Down Expand Up @@ -143,10 +142,6 @@ export class FargateProfile extends Construct implements ITaggable {
constructor(scope: Construct, id: string, props: FargateProfileProps) {
super(scope, id);

const provider = ClusterResourceProvider.getOrCreate(this, {
onEventLayer: props.cluster.onEventLayer,
});

this.podExecutionRole = props.podExecutionRole ?? new iam.Role(this, 'PodExecutionRole', {
assumedBy: new iam.ServicePrincipal('eks-fargate-pods.amazonaws.com'),
managedPolicies: [iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonEKSFargatePodExecutionRolePolicy')],
Expand Down Expand Up @@ -174,23 +169,22 @@ export class FargateProfile extends Construct implements ITaggable {

this.tags = new TagManager(TagType.MAP, 'AWS::EKS::FargateProfile');

const resource = new CustomResource(this, 'Resource', {
serviceToken: provider.serviceToken,
resourceType: FARGATE_PROFILE_RESOURCE_TYPE,
properties: {
AssumeRoleArn: props.cluster.adminRole.roleArn,
Config: {
clusterName: props.cluster.clusterName,
fargateProfileName: props.fargateProfileName,
podExecutionRoleArn: this.podExecutionRole.roleArn,
selectors: props.selectors,
subnets,
tags: Lazy.any({ produce: () => this.tags.renderTags() }),
},
},
const resource = new CfnFargateProfile(this, 'Resource', {
clusterName: props.cluster.clusterName,
fargateProfileName: props.fargateProfileName,
podExecutionRoleArn: this.podExecutionRole.roleArn,
selectors: props.selectors.map((s) => ({
namespace: s.namespace,
labels: Object.entries(s.labels ?? {}).map((e) => ({
key: e[0],
value: e[1],
})),
})),
subnets,
tags: this.tags.renderTags(),
});

this.fargateProfileArn = resource.getAttString('fargateProfileArn');
this.fargateProfileArn = resource.attrArn;
this.fargateProfileName = resource.ref;

// Fargate profiles must be created sequentially. If other profile(s) already
Expand Down
Loading

0 comments on commit e745df0

Please sign in to comment.