ServiceAccount
Service Account.
Example
declare const cluster: eks.Cluster;
new eks.ServiceAccount(this, 'ServiceAccount', {
cluster,
name: 'test-sa',
namespace: 'default',
identityType: eks.IdentityType.POD_IDENTITY,
});
# cluster: eks.Cluster
eks.ServiceAccount(self, "ServiceAccount",
cluster=cluster,
name="test-sa",
namespace="default",
identity_type=eks.IdentityType.POD_IDENTITY
)
Cluster cluster;
ServiceAccount.Builder.create(this, "ServiceAccount")
.cluster(cluster)
.name("test-sa")
.namespace("default")
.identityType(IdentityType.POD_IDENTITY)
.build();
// Install: dotnet add package Amazon.CDK.Lib
Cluster cluster;
new ServiceAccount(this, "ServiceAccount", new ServiceAccountProps {
Cluster = cluster,
Name = "test-sa",
Namespace = "default",
IdentityType = IdentityType.POD_IDENTITY
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var cluster Cluster
eks.NewServiceAccount(this, jsii.String("ServiceAccount"), &ServiceAccountProps{
Cluster: Cluster,
Name: jsii.String("test-sa"),
Namespace: jsii.String("default"),
IdentityType: eks.IdentityType_POD_IDENTITY,
})
Initializer
new ServiceAccount(scope: Construct, id: string, props: ServiceAccountProps)
ServiceAccount(scope: Construct, id: str, props: ServiceAccountProps)
new ServiceAccount(Construct scope, String id, ServiceAccountProps props)
new ServiceAccount(Construct scope, string id, ServiceAccountProps props)
NewServiceAccount(Scope Construct, Id *string, Props ServiceAccountProps)
Construct Props
annotations{ [key: string]: string }annotationstyping.Mapping[str, str]annotationsMap<String, String>AnnotationsIDictionary<string, string>Annotations*map[string]*string= no additional annotations#identityTypeIdentityTypeidentity_typeIdentityTypeidentityTypeIdentityTypeIdentityTypeIdentityTypeIdentityTypeIdentityType= IdentityType.IRSA#labels{ [key: string]: string }labelstyping.Mapping[str, str]labelsMap<String, String>LabelsIDictionary<string, string>Labels*map[string]*string= no additional labels#The name of a ServiceAccount object must be a valid DNS subdomain name. https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
default
Default: If no name is given, it will use the id of the resource.
All namespace names must be valid RFC 1123 DNS labels. https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/#namespaces-and-dns
overwriteServiceAccountbooleanoverwrite_service_accountbooloverwriteServiceAccountBooleanOverwriteServiceAccountboolOverwriteServiceAccount*bool= false#If this is set, we will use kubectl apply instead of kubectl create when the service account is created. Otherwise, if there is already a service account in the cluster with the same name, the operation will fail.
removalPolicyRemovalPolicyremoval_policyRemovalPolicyremovalPolicyRemovalPolicyRemovalPolicyRemovalPolicyRemovalPolicyRemovalPolicy= RemovalPolicy.DESTROY#notes
The removal policy controls what happens to the resources if they stop 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
Properties
assumeRoleActionstringassume_role_actionstrassumeRoleActionStringAssumeRoleActionstringAssumeRoleAction*stringrequired#grantPrincipalIPrincipalgrant_principalIPrincipalgrantPrincipalIPrincipalGrantPrincipalIPrincipalGrantPrincipalIPrincipalrequired#policyFragmentPrincipalPolicyFragmentpolicy_fragmentPrincipalPolicyFragmentpolicyFragmentPrincipalPolicyFragmentPolicyFragmentPrincipalPolicyFragmentPolicyFragmentPrincipalPolicyFragmentrequired#serviceAccountNamestringservice_account_namestrserviceAccountNameStringServiceAccountNamestringServiceAccountName*stringrequired#serviceAccountNamespacestringservice_account_namespacestrserviceAccountNamespaceStringServiceAccountNamespacestringServiceAccountNamespace*stringrequired#Methods
addToPrincipalPolicy(statement: PolicyStatement): AddToPrincipalPolicyResultdef add_to_principal_policy(self, statement: PolicyStatement) -> AddToPrincipalPolicyResultpublic AddToPrincipalPolicyResult addToPrincipalPolicy(PolicyStatement statement)public AddToPrincipalPolicyResult AddToPrincipalPolicy(PolicyStatement statement)func AddToPrincipalPolicy(Statement PolicyStatement) AddToPrincipalPolicyResult#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#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#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#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