You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(eks): programmatic definition of kubernetes resources (#3510)
* chore: update package-lock.json
* feat(eks): define kubernetes resources
This change allows defining arbitrary Kubernetes resources within an EKS cluster.
* nice!
* update readme
* Update README.md
* feat(events): ability to add cross-account targets (#3323)
This adds the capability of adding a target to an event rule
that belongs to a different account than the rule itself.
Required for things like cross-account CodePipelines with source actions triggered by events.
* chore(ci): add mergify config file (#3502)
* chore: update jsii to 0.14.3 (#3513)
* fix(iam): correctly limit the default PolicyName to 128 characters (#3487)
Our logic for trimming the length of the default IAM policy name was not working,
as it wasn't updated when logicalId became a Token rather than a literate string,
and so it was never actually triggered
(it just checked that the display name of the Token was less than 128 characters,
which it always is).
The fix is to resolve the logical ID Token before applying the trimming logic.
Fixes#3402
* v1.3.0 (#3516)
See CHANGELOG
* fix: typo in restapi.ts (#3530)
* feat(ecs): container dependencies (#3032)
Add new addContainerDependencies method to allow for container dependencies
Fixes#2490
* feat(s3-deployment): CloudFront invalidation (#3213)
see #3106
* docs(core): findChild gets direct child only (#3512)
* doc(iam): update references to addManagedPolicy (#3511)
* fix(sqs): do not emit grants to the AWS-managed encryption key (#3169)
Grants on the `alias/aws/sqs` KMS key alias are not necessary since the
key will implicitly allow for it's intended usage to be fulfilled (as
opposed to how you have to manage grants yourself when using a
user-managed key instead).
This removes the statement that was generated using an invalid resource
entry.
Fixes#2794
* fix(lambda): allow ArnPrincipal in grantInvoke (#3501)
Fixes#3264
I'm trying to allow a lambda function in another account to be able to invoke my CDK generated lambda function. This works through the CLI like so:
aws lambda add-permission --function-name=myFunction --statement-id=ABoldStatement --action=lambda:InvokeFunction --principal=arn:aws:iam::{account_id}:role/a_lambda_execution_role
But CDK doesn't seem to allow me to add an ArnPrincipal doing something like this:
myFunction.grantInvoke(new iam.ArnPrincipal(props.myARN))
With the error:
Invalid principal type for Lambda permission statement: ArnPrincipal. Supported: AccountPrincipal, ServicePrincipal
This PR allows ArnPrincipal to be passed to lambda.grantInvoke.
There might be some additional validation required on the exact ARN as I believe only some ARNs are supported by lambda add-permission
* chore(contrib): remove API stabilization disclaimer
* fix(ssm): add GetParameters action to grantRead() (#3546)
* misc
* rename `KubernetesManifest` to `KubernetesResource` and `addResource`
* move AWS Auth APIs to `cluster.awsAuth` and expose `AwsAuth`
* remove the yaml library (we can just use a JSON stream)
* add support for adding accounts to aws-auth
* fix cluster deletion bug
* move kubctl app info to constants
* addManifest => addResource
* update test expectations
* add unit test for customresrouce.ref
* fix sample link
This construct library allows you to define and create [Amazon Elastic Container Service for Kubernetes (EKS)](https://aws.amazon.com/eks/) clusters programmatically.
18
+
This construct library allows you to define [Amazon Elastic Container Service
19
+
for Kubernetes (EKS)](https://aws.amazon.com/eks/) clusters programmatically.
19
20
20
-
### Example
21
+
This library also supports programmatically defining Kubernetes resource
22
+
manifests within EKS clusters.
21
23
22
-
The following example shows how to start an EKS cluster and how to
23
-
add worker nodes to it:
24
+
This example defines an Amazon EKS cluster with a single pod:
24
25
25
-
[starting a cluster example](test/integ.eks-cluster.lit.ts)
that creates the cluster, is automatically granted `system:masters` permissions
205
+
in the cluster's RBAC configuration.
206
+
207
+
In order to allow programmatically defining **Kubernetes resources** in your AWS
208
+
CDK app and provisioning them through AWS CloudFormation, we will need to assume
209
+
this "masters" role every time we want to issue `kubectl` operations against your
210
+
cluster.
211
+
212
+
At the moment, the [AWS::EKS::Cluster](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-cluster.html)
213
+
AWS CloudFormation resource does not support this behavior, so in order to
214
+
support "programmatic kubectl", such as applying manifests
215
+
and mapping IAM roles from within your CDK application, the Amazon EKS
216
+
construct library uses a custom resource for provisioning the cluster.
217
+
This custom resource is executed with an IAM role that we can then use
218
+
to issue `kubectl` commands.
219
+
220
+
The default behavior of this library is to use this custom resource in order
221
+
to retain programmatic control over the cluster. In other words: to allow
222
+
you to define Kubernetes resources in your CDK code instead of having to
223
+
manage your Kubernetes applications through a separate system.
224
+
225
+
One of the implications of this design is that, by default, the user who
226
+
provisioned the AWS CloudFormation stack (executed `cdk deploy`) will
227
+
not have administrative privileges on the EKS cluster.
228
+
229
+
1. Additional resources will be synthesized into your template (the AWS Lambda
230
+
function, the role and policy).
231
+
2. As described in [Interacting with Your Cluster](#interacting-with-your-cluster),
232
+
if you wish to be able to manually interact with your cluster, you will need
233
+
to map an IAM role or user to the `system:masters` group. This can be either
234
+
done by specifying a `mastersRole` when the cluster is defined, calling
235
+
`cluster.addMastersRole` or explicitly mapping an IAM role or IAM user to the
236
+
relevant Kubernetes RBAC groups using `cluster.addRoleMapping` and/or
237
+
`cluster.addUserMapping`.
238
+
239
+
If you wish to disable the programmatic kubectl behavior and use the standard
240
+
AWS::EKS::Cluster resource, you can specify `kubectlEnabled: false` when you define
241
+
the cluster:
242
+
243
+
```ts
244
+
neweks.Cluster(this, 'cluster', {
245
+
vpc: vpc,
246
+
kubectlEnabled: false
247
+
});
248
+
```
249
+
250
+
**Take care**: a change in this property will cause the cluster to be destroyed
251
+
and a new cluster to be created.
252
+
253
+
When kubectl is disabled, you should be aware of the following:
254
+
255
+
1. When you log-in to your cluster, you don't need to specify `--role-arn` as long as you are using the same user that created
256
+
the cluster.
257
+
2. As described in the Amazon EKS User Guide, you will need to manually
258
+
edit the [aws-auth ConfigMap](https://docs.aws.amazon.com/eks/latest/userguide/add-user-role.html) when you add capacity in order to map
259
+
the IAM instance role to RBAC to allow nodes to join the cluster.
260
+
3. Any `eks.Cluster` APIs that depend on programmatic kubectl support will fail with an error: `cluster.addResource`, `cluster.awsAuth`, `props.mastersRole`.
261
+
44
262
### Roadmap
45
263
46
-
-[ ]Add ability to start tasks on clusters using CDK (similar to ECS's "`Service`" concept).
47
-
-[ ]Describe how to set up AutoScaling (how to combine EC2 and Kubernetes scaling)
264
+
-[ ]AutoScaling (combine EC2 and Kubernetes scaling)
0 commit comments