-
Notifications
You must be signed in to change notification settings - Fork 1.1k
test(samples/cloudwatch-applicationsignals-mcp): Added IaC for EKS deployment using CDK and terraform #1732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
...tionsignals-mcp/get-enablement-guide-samples/infrastructure/eks/cdk/config/python-flask.json
Show resolved
Hide resolved
...als-mcp/get-enablement-guide-samples/infrastructure/eks/terraform/config/python-flask.tfvars
Show resolved
Hide resolved
...gnals-mcp/get-enablement-guide-samples/infrastructure/eks/terraform/terraform.tfvars.example
Outdated
Show resolved
Hide resolved
samples/cloudwatch-applicationsignals-mcp/get-enablement-guide-samples/.gitignore
Show resolved
Hide resolved
samples/cloudwatch-applicationsignals-mcp/get-enablement-guide-samples/README.md
Outdated
Show resolved
Hide resolved
...dwatch-applicationsignals-mcp/get-enablement-guide-samples/infrastructure/eks/cdk/bin/cdk.ts
Outdated
Show resolved
Hide resolved
...atch-applicationsignals-mcp/get-enablement-guide-samples/infrastructure/eks/cdk/package.json
Outdated
Show resolved
Hide resolved
| ### EC2 Deployment | ||
|
|
||
| **Using CDK:** | ||
| #### Using CDK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't have a strong opinion either way. will you update other sections in your README PR for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not too familiar with eks, but wondering if we need to explicitly increase hop limit. had to do this for EC2 so my docker container could contact IMDS to get credentials. might just be an EC2 problem though
| resource "aws_eks_cluster" "app_cluster" { | ||
| name = "${var.app_name}-cluster" | ||
| role_arn = aws_iam_role.cluster_role.arn | ||
| version = "1.30" | ||
|
|
||
| vpc_config { | ||
| subnet_ids = data.aws_subnets.public.ids | ||
| endpoint_private_access = true | ||
| endpoint_public_access = true | ||
| } | ||
|
|
||
| depends_on = [ | ||
| aws_iam_role_policy_attachment.cluster_policy | ||
| ] | ||
| } |
Check failure
Code scanning / checkov
Ensure Amazon EKS public endpoint disabled Error
| resource "aws_eks_cluster" "app_cluster" { | ||
| name = "${var.app_name}-cluster" | ||
| role_arn = aws_iam_role.cluster_role.arn | ||
| version = "1.30" | ||
|
|
||
| vpc_config { | ||
| subnet_ids = data.aws_subnets.public.ids | ||
| endpoint_private_access = true | ||
| endpoint_public_access = true | ||
| } | ||
|
|
||
| depends_on = [ | ||
| aws_iam_role_policy_attachment.cluster_policy | ||
| ] | ||
| } |
Check failure
Code scanning / checkov
Ensure Amazon EKS control plane logging is enabled for all log types Error
| resource "aws_eks_cluster" "app_cluster" { | ||
| name = "${var.app_name}-cluster" | ||
| role_arn = aws_iam_role.cluster_role.arn | ||
| version = "1.30" | ||
|
|
||
| vpc_config { | ||
| subnet_ids = data.aws_subnets.public.ids | ||
| endpoint_private_access = true | ||
| endpoint_public_access = true | ||
| } | ||
|
|
||
| depends_on = [ | ||
| aws_iam_role_policy_attachment.cluster_policy | ||
| ] | ||
| } |
Check failure
Code scanning / checkov
Ensure EKS Cluster has Secrets Encryption Enabled Error
| resource "aws_eks_cluster" "app_cluster" { | ||
| name = "${var.app_name}-cluster" | ||
| role_arn = aws_iam_role.cluster_role.arn | ||
| version = "1.30" | ||
|
|
||
| vpc_config { | ||
| subnet_ids = data.aws_subnets.public.ids | ||
| endpoint_private_access = true | ||
| endpoint_public_access = true | ||
| } | ||
|
|
||
| depends_on = [ | ||
| aws_iam_role_policy_attachment.cluster_policy | ||
| ] | ||
| } |
Check failure
Code scanning / checkov
Ensure Amazon EKS public endpoint not accessible to 0.0.0.0/0 Error
| resource "kubernetes_deployment" "app" { | ||
| metadata { | ||
| name = var.app_name | ||
| } | ||
|
|
||
| spec { | ||
| replicas = 1 | ||
|
|
||
| selector { | ||
| match_labels = { | ||
| app = var.app_name | ||
| } | ||
| } | ||
|
|
||
| template { | ||
| metadata { | ||
| labels = { | ||
| app = var.app_name | ||
| } | ||
| } | ||
|
|
||
| spec { | ||
| container { | ||
| image = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/${var.image_name}:latest" | ||
| name = var.app_name | ||
|
|
||
| port { | ||
| container_port = var.port | ||
| } | ||
|
|
||
| env { | ||
| name = "PORT" | ||
| value = tostring(var.port) | ||
| } | ||
|
|
||
| env { | ||
| name = "AWS_REGION" | ||
| value = data.aws_region.current.name | ||
| } | ||
|
|
||
| lifecycle { | ||
| post_start { | ||
| exec { | ||
| command = ["sh", "-c", "nohup bash /app/generate-traffic.sh > /dev/null 2>&1 &"] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| depends_on = [aws_eks_node_group.app_nodes] | ||
| } |
Check failure
Code scanning / checkov
CPU requests should be set Error
| resource "kubernetes_deployment" "app" { | ||
| metadata { | ||
| name = var.app_name | ||
| } | ||
|
|
||
| spec { | ||
| replicas = 1 | ||
|
|
||
| selector { | ||
| match_labels = { | ||
| app = var.app_name | ||
| } | ||
| } | ||
|
|
||
| template { | ||
| metadata { | ||
| labels = { | ||
| app = var.app_name | ||
| } | ||
| } | ||
|
|
||
| spec { | ||
| container { | ||
| image = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/${var.image_name}:latest" | ||
| name = var.app_name | ||
|
|
||
| port { | ||
| container_port = var.port | ||
| } | ||
|
|
||
| env { | ||
| name = "PORT" | ||
| value = tostring(var.port) | ||
| } | ||
|
|
||
| env { | ||
| name = "AWS_REGION" | ||
| value = data.aws_region.current.name | ||
| } | ||
|
|
||
| lifecycle { | ||
| post_start { | ||
| exec { | ||
| command = ["sh", "-c", "nohup bash /app/generate-traffic.sh > /dev/null 2>&1 &"] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| depends_on = [aws_eks_node_group.app_nodes] | ||
| } |
Check failure
Code scanning / checkov
Liveness Probe Should be Configured Error
| resource "kubernetes_deployment" "app" { | ||
| metadata { | ||
| name = var.app_name | ||
| } | ||
|
|
||
| spec { | ||
| replicas = 1 | ||
|
|
||
| selector { | ||
| match_labels = { | ||
| app = var.app_name | ||
| } | ||
| } | ||
|
|
||
| template { | ||
| metadata { | ||
| labels = { | ||
| app = var.app_name | ||
| } | ||
| } | ||
|
|
||
| spec { | ||
| container { | ||
| image = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/${var.image_name}:latest" | ||
| name = var.app_name | ||
|
|
||
| port { | ||
| container_port = var.port | ||
| } | ||
|
|
||
| env { | ||
| name = "PORT" | ||
| value = tostring(var.port) | ||
| } | ||
|
|
||
| env { | ||
| name = "AWS_REGION" | ||
| value = data.aws_region.current.name | ||
| } | ||
|
|
||
| lifecycle { | ||
| post_start { | ||
| exec { | ||
| command = ["sh", "-c", "nohup bash /app/generate-traffic.sh > /dev/null 2>&1 &"] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| depends_on = [aws_eks_node_group.app_nodes] | ||
| } |
Check failure
Code scanning / checkov
Image should use digest Error
| resource "kubernetes_deployment" "app" { | ||
| metadata { | ||
| name = var.app_name | ||
| } | ||
|
|
||
| spec { | ||
| replicas = 1 | ||
|
|
||
| selector { | ||
| match_labels = { | ||
| app = var.app_name | ||
| } | ||
| } | ||
|
|
||
| template { | ||
| metadata { | ||
| labels = { | ||
| app = var.app_name | ||
| } | ||
| } | ||
|
|
||
| spec { | ||
| container { | ||
| image = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/${var.image_name}:latest" | ||
| name = var.app_name | ||
|
|
||
| port { | ||
| container_port = var.port | ||
| } | ||
|
|
||
| env { | ||
| name = "PORT" | ||
| value = tostring(var.port) | ||
| } | ||
|
|
||
| env { | ||
| name = "AWS_REGION" | ||
| value = data.aws_region.current.name | ||
| } | ||
|
|
||
| lifecycle { | ||
| post_start { | ||
| exec { | ||
| command = ["sh", "-c", "nohup bash /app/generate-traffic.sh > /dev/null 2>&1 &"] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| depends_on = [aws_eks_node_group.app_nodes] | ||
| } |
Check failure
Code scanning / checkov
Readiness Probe Should be Configured Error
| resource "kubernetes_deployment" "app" { | ||
| metadata { | ||
| name = var.app_name | ||
| } | ||
|
|
||
| spec { | ||
| replicas = 1 | ||
|
|
||
| selector { | ||
| match_labels = { | ||
| app = var.app_name | ||
| } | ||
| } | ||
|
|
||
| template { | ||
| metadata { | ||
| labels = { | ||
| app = var.app_name | ||
| } | ||
| } | ||
|
|
||
| spec { | ||
| container { | ||
| image = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/${var.image_name}:latest" | ||
| name = var.app_name | ||
|
|
||
| port { | ||
| container_port = var.port | ||
| } | ||
|
|
||
| env { | ||
| name = "PORT" | ||
| value = tostring(var.port) | ||
| } | ||
|
|
||
| env { | ||
| name = "AWS_REGION" | ||
| value = data.aws_region.current.name | ||
| } | ||
|
|
||
| lifecycle { | ||
| post_start { | ||
| exec { | ||
| command = ["sh", "-c", "nohup bash /app/generate-traffic.sh > /dev/null 2>&1 &"] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| depends_on = [aws_eks_node_group.app_nodes] | ||
| } |
Check failure
Code scanning / checkov
Memory Limits should be set Error
| resource "kubernetes_service" "app" { | ||
| metadata { | ||
| name = "${var.app_name}-service" | ||
| } | ||
|
|
||
| spec { | ||
| selector = { | ||
| app = var.app_name | ||
| } | ||
|
|
||
| port { | ||
| port = var.port | ||
| target_port = var.port | ||
| } | ||
|
|
||
| type = "ClusterIP" | ||
| } | ||
|
|
||
| depends_on = [kubernetes_deployment.app] | ||
| } No newline at end of file |
Check failure
Code scanning / checkov
The default namespace should not be used Error
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1732 +/- ##
=======================================
Coverage 90.26% 90.26%
=======================================
Files 781 781
Lines 59912 59912
Branches 9718 9718
=======================================
Hits 54077 54077
Misses 3646 3646
Partials 2189 2189 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| throw new Error(`Invalid config file name: ${configFile}`); | ||
| } | ||
|
|
||
| const configPath = path.join(configDir, configFile); |
Check warning
Code scanning / Semgrep OSS
Semgrep Finding: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal Warning
| } | ||
|
|
||
| # EKS Cluster | ||
| resource "aws_eks_cluster" "app_cluster" { |
Check warning
Code scanning / Semgrep OSS
Semgrep Finding: terraform.lang.security.eks-public-endpoint-enabled.eks-public-endpoint-enabled Warning
|
|
||
| # EKS Cluster | ||
| resource "aws_eks_cluster" "app_cluster" { | ||
| name = "${var.app_name}-cluster" |
Check warning
Code scanning / Semgrep OSS
Semgrep Finding: terraform.lang.security.eks-insufficient-control-plane-logging.eks-insufficient-control-plane-logging Warning
Fixes
Summary
Changes
This PR adds Terraform and CDK infrastructure-as-code for deploying Docker applications to EKS for testing AWS Application Signals enablement via the get_enablement_guide MCP tool.
Infrastructure as Code for EKS Deployment
This commit adds comprehensive Infrastructure as Code (IaC) support for EKS deployments using both CDK and Terraform:
CDK Implementation
package.json,tsconfig.json, andcdk.jsonbin/cdk.tsfor stack deploymentTerraform Implementation
main.tf(244 lines)Documentation Updates
Files Added/Modified
This enables users to deploy EKS infrastructure for Application Signals testing using their preferred IaC tool with framework-specific configurations.
User experience
N/A
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change? (Y/N)
N
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.