KubectlProvider
Implementation of Kubectl Lambda.
Example
const handlerRole = iam.Role.fromRoleArn(this, 'HandlerRole', 'arn:aws:iam::123456789012:role/lambda-role');
// get the serviceToken from the custom resource provider
const functionArn = lambda.Function.fromFunctionName(this, 'ProviderOnEventFunc', 'ProviderframeworkonEvent-XXX').functionArn;
const kubectlProvider = eks.KubectlProvider.fromKubectlProviderAttributes(this, 'KubectlProvider', {
serviceToken: functionArn,
role: handlerRole,
});
const cluster = eks.Cluster.fromClusterAttributes(this, 'Cluster', {
clusterName: 'cluster',
kubectlProvider,
});
handler_role = iam.Role.from_role_arn(self, "HandlerRole", "arn:aws:iam::123456789012:role/lambda-role")
# get the serviceToken from the custom resource provider
function_arn = lambda_.Function.from_function_name(self, "ProviderOnEventFunc", "ProviderframeworkonEvent-XXX").function_arn
kubectl_provider = eks.KubectlProvider.from_kubectl_provider_attributes(self, "KubectlProvider",
service_token=function_arn,
role=handler_role
)
cluster = eks.Cluster.from_cluster_attributes(self, "Cluster",
cluster_name="cluster",
kubectl_provider=kubectl_provider
)
IRole handlerRole = Role.fromRoleArn(this, "HandlerRole", "arn:aws:iam::123456789012:role/lambda-role");
// get the serviceToken from the custom resource provider
String functionArn = Function.fromFunctionName(this, "ProviderOnEventFunc", "ProviderframeworkonEvent-XXX").getFunctionArn();
IKubectlProvider kubectlProvider = KubectlProvider.fromKubectlProviderAttributes(this, "KubectlProvider", KubectlProviderAttributes.builder()
.serviceToken(functionArn)
.role(handlerRole)
.build());
ICluster cluster = Cluster.fromClusterAttributes(this, "Cluster", ClusterAttributes.builder()
.clusterName("cluster")
.kubectlProvider(kubectlProvider)
.build());
// Install: dotnet add package Amazon.CDK.Lib
var handlerRole = Role.FromRoleArn(this, "HandlerRole", "arn:aws:iam::123456789012:role/lambda-role");
// get the serviceToken from the custom resource provider
var functionArn = Function.FromFunctionName(this, "ProviderOnEventFunc", "ProviderframeworkonEvent-XXX").FunctionArn;
var kubectlProvider = KubectlProvider.FromKubectlProviderAttributes(this, "KubectlProvider", new KubectlProviderAttributes {
ServiceToken = functionArn,
Role = handlerRole
});
var cluster = Cluster.FromClusterAttributes(this, "Cluster", new ClusterAttributes {
ClusterName = "cluster",
KubectlProvider = kubectlProvider
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
handlerRole := iam.Role_FromRoleArn(this, jsii.String("HandlerRole"), jsii.String("arn:aws:iam::123456789012:role/lambda-role"))
// get the serviceToken from the custom resource provider
functionArn := lambda.Function_FromFunctionName(this, jsii.String("ProviderOnEventFunc"), jsii.String("ProviderframeworkonEvent-XXX")).FunctionArn
kubectlProvider := eks.KubectlProvider_FromKubectlProviderAttributes(this, jsii.String("KubectlProvider"), &KubectlProviderAttributes{
ServiceToken: functionArn,
Role: handlerRole,
})
cluster := eks.Cluster_FromClusterAttributes(this, jsii.String("Cluster"), &ClusterAttributes{
ClusterName: jsii.String("cluster"),
KubectlProvider: KubectlProvider,
})
Initializer
new KubectlProvider(scope: Construct, id: string, props: KubectlProviderProps)
KubectlProvider(scope: Construct, id: str, props: KubectlProviderProps)
new KubectlProvider(Construct scope, String id, KubectlProviderProps props)
new KubectlProvider(Construct scope, string id, KubectlProviderProps props)
NewKubectlProvider(Scope Construct, Id *string, Props KubectlProviderProps)
Construct Props
awscliLayeroptionalILayerVersionawscli_layeroptionalILayerVersionawscliLayeroptionalILayerVersionAwscliLayeroptionalILayerVersionAwscliLayeroptionalILayerVersion#Default: If not defined, a default layer will be used containing the AWS CLI 2.x.
environmentoptional{ [key: string]: string }environmentoptionaltyping.Mapping[str, str]environmentoptionalMap<String, String>EnvironmentoptionalIDictionary<string, string>Environmentoptional*map[string]*string#Default: No custom environment variables
kubectlLayerILayerVersionkubectl_layerILayerVersionkubectlLayerILayerVersionKubectlLayerILayerVersionKubectlLayerILayerVersionrequired#privateSubnetsoptionalISubnet[]private_subnetsoptionaltyping.List[ISubnet]privateSubnetsoptionalList<ISubnet>PrivateSubnetsoptionalISubnet[]PrivateSubnetsoptional*[]ISubnet#Default: the k8s is accessible publicly
If not specified, the k8s endpoint is expected to be accessible publicly.
removalPolicyoptionalRemovalPolicyremoval_policyoptionalRemovalPolicyremovalPolicyoptionalRemovalPolicyRemovalPolicyoptionalRemovalPolicyRemovalPolicyoptionalRemovalPolicy= RemovalPolicy.DESTROY#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
Default: if not specified, the default role created by a lambda function will be used.
The role should be mapped to the system:masters Kubernetes RBAC role.
This role is directly passed to the lambda handler that sends Kube Ctl commands to the cluster.
securityGroupoptionalISecurityGroupsecurity_groupoptionalISecurityGroupsecurityGroupoptionalISecurityGroupSecurityGroupoptionalISecurityGroupSecurityGroupoptionalISecurityGroupdeprecated#Default: If not specified, the k8s endpoint is expected to be accessible publicly.
securityGroupsoptionalISecurityGroup[]security_groupsoptionaltyping.List[ISecurityGroup]securityGroupsoptionalList<ISecurityGroup>SecurityGroupsoptionalISecurityGroup[]SecurityGroupsoptional*[]ISecurityGroup#Default: If not specified, the k8s endpoint is expected to be accessible publicly.
Properties
Methods
fromKubectlProviderAttributes(scope: Construct, id: string, attrs: KubectlProviderAttributes): IKubectlProvider@staticmethod def from_kubectl_provider_attributes(scope: Construct, id: str, attrs: KubectlProviderAttributes) -> IKubectlProviderpublic static IKubectlProvider fromKubectlProviderAttributes(Construct scope, String id, KubectlProviderAttributes attrs)public static IKubectlProvider FromKubectlProviderAttributes(Construct scope, string id, KubectlProviderAttributes attrs)func FromKubectlProviderAttributes(Scope Construct, Id *string, Attrs KubectlProviderAttributes) IKubectlProviderstatic#3 parameters
Parameters
scopescopescopescopeScope— Construct.ididididId— an id of resource.attrsattrsattrsattrsAttrs— attributes for the provider.
getKubectlProvider(scope: Construct, cluster: ICluster): IKubectlProvider@staticmethod def get_kubectl_provider(scope: Construct, cluster: ICluster) -> IKubectlProviderpublic static IKubectlProvider getKubectlProvider(Construct scope, ICluster cluster)public static IKubectlProvider GetKubectlProvider(Construct scope, ICluster cluster)func GetKubectlProvider(Scope Construct, Cluster ICluster) IKubectlProviderstatic#2 parameters
Parameters
scopescopescopescopeScope— Construct.clusterclusterclusterclusterCluster— k8s cluster.
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