Skip to content
v2.275.0

FargateProfile ​

Fargate profiles allows an administrator to declare which pods run on Fargate.

This declaration is done through the profile’s selectors. Each profile can have up to five selectors that contain a namespace and optional labels. You must define a namespace for every selector. The label field consists of multiple optional key-value pairs. Pods that match a selector (by matching a namespace for the selector and all of the labels specified in the selector) are scheduled on Fargate. If a namespace selector is defined without any labels, Amazon EKS will attempt to schedule all pods that run in that namespace onto Fargate using the profile. If a to-be-scheduled pod matches any of the selectors in the Fargate profile, then that pod is scheduled on Fargate.

If a pod matches multiple Fargate profiles, Amazon EKS picks one of the matches at random. In this case, you can specify which profile a pod should use by adding the following Kubernetes label to the pod specification: eks.amazonaws.com/fargate-profile: profile_name. However, the pod must still match a selector in that profile in order to be scheduled onto Fargate.

Example ​

ts
declare const cluster: eks.Cluster;
new eks.FargateProfile(this, 'MyProfile', {
  cluster,
  selectors: [ { namespace: 'default' } ],
});
python
# cluster: eks.Cluster

eks.FargateProfile(self, "MyProfile",
    cluster=cluster,
    selectors=[eks.Selector(namespace="default")]
)
java
Cluster cluster;

FargateProfile.Builder.create(this, "MyProfile")
        .cluster(cluster)
        .selectors(List.of(Selector.builder().namespace("default").build()))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
Cluster cluster;

new FargateProfile(this, "MyProfile", new FargateProfileProps {
    Cluster = cluster,
    Selectors = new [] { new Selector { Namespace = "default" } }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var cluster Cluster

eks.NewFargateProfile(this, jsii.String("MyProfile"), &FargateProfileProps{
	Cluster: Cluster,
	Selectors: []Selector{
		&Selector{
			Namespace: jsii.String("default"),
		},
	},
})

Initializer ​

ts
new FargateProfile(scope: Construct, id: string, props: FargateProfileProps)
python
FargateProfile(scope: Construct, id: str, props: FargateProfileProps)
java
new FargateProfile(Construct scope, String id, FargateProfileProps props)
csharp
new FargateProfile(Construct scope, string id, FargateProfileProps props)
go
NewFargateProfile(Scope Construct, Id *string, Props FargateProfileProps)

Construct Props ​

clusterClusterclusterClusterclusterClusterClusterClusterClusterClusterrequired#
The EKS cluster to apply the Fargate profile to.

[disable-awslint:ref-via-interface]

fargateProfileNameoptionalstringfargate_profile_nameoptionalstrfargateProfileNameoptionalStringFargateProfileNameoptionalstringFargateProfileNameoptional*string= generated#
The name of the Fargate profile.
podExecutionRoleoptionalIRolepod_execution_roleoptionalIRolepodExecutionRoleoptionalIRolePodExecutionRoleoptionalIRolePodExecutionRoleoptionalIRole#
The pod execution role to use for pods that match the selectors in the Fargate profile.

Default: a role will be automatically created

The pod execution role allows Fargate infrastructure to register with your cluster as a node, and it provides read access to Amazon ECR image repositories.

removalPolicyoptionalRemovalPolicyremoval_policyoptionalRemovalPolicyremovalPolicyoptionalRemovalPolicyRemovalPolicyoptionalRemovalPolicyRemovalPolicyoptionalRemovalPolicy= RemovalPolicy.DESTROY#
The removal policy applied to the custom resource that manages the Fargate profile.
notes

The removal policy controls what happens to the resource if it stops being managed by CloudFormation. This can happen in one of three situations:

  • The resource is removed from the template, so CloudFormation stops managing it
  • A change to the resource is made that requires it to be replaced, so CloudFormation stops managing it
  • The stack is deleted, so CloudFormation stops managing all resources in it
selectorsSelector[]selectorstyping.List[Selector]selectorsList<Selector>SelectorsSelector[]Selectors*[]Selectorrequired#
The selectors to match for pods to use this Fargate profile.

Each selector must have an associated namespace. Optionally, you can also specify labels for a namespace.

At least one selector is required and you may specify up to five selectors.

subnetSelectionoptionalSubnetSelectionsubnet_selectionoptionalSubnetSelectionsubnetSelectionoptionalSubnetSelectionSubnetSelectionoptionalSubnetSelectionSubnetSelectionoptionalSubnetSelection#
Select which subnets to launch your pods into.

Default: all private subnets of the VPC are selected.

At this time, pods running on Fargate are not assigned public IP addresses, so only private subnets (with no direct route to an Internet Gateway) are allowed.

You must specify the VPC to customize the subnet selection

vpcoptionalIVpcvpcoptionalIVpcvpcoptionalIVpcVpcoptionalIVpcVpcoptionalIVpc#
The VPC from which to select subnets to launch your pods into.

Default: all private subnets used by the EKS cluster

By default, all private subnets are selected. You can customize this using subnetSelection.

Properties ​

fargateProfileArnstringfargate_profile_arnstrfargateProfileArnStringFargateProfileArnstringFargateProfileArn*string#
The full Amazon Resource Name (ARN) of the Fargate profile.
fargateProfileNamestringfargate_profile_namestrfargateProfileNameStringFargateProfileNamestringFargateProfileName*string#
The name of the Fargate profile.
nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.
podExecutionRoleIRolepod_execution_roleIRolepodExecutionRoleIRolePodExecutionRoleIRolePodExecutionRoleIRole#
The pod execution role to use for pods that match the selectors in the Fargate profile.

The pod execution role allows Fargate infrastructure to register with your cluster as a node, and it provides read access to Amazon ECR image repositories.

Resource tags.

Methods ​

isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

1 parameter · returns

Parameters

  • mixinsmixinsmixinsmixinsMixins — The mixins to apply.

Returns: This construct for chaining