Skip to content
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

feat(eks-vpc): verify available ec2 elastic ips quotas before apply #215

Merged
merged 22 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .github/workflows/daily-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ jobs:
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: Cache asdf installation
id: cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: |
/home/runner/.asdf
key: ${{ runner.os }}-tooling-${{ hashFiles('**/.tool-versions') }}
restore-keys: |
${{ runner.os }}-tooling-

- name: Install tooling using asdf
uses: asdf-vm/actions/install@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 # v3
with:
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/test-gha-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,6 @@ jobs:
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: Cache asdf installation
id: cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: |
/home/runner/.asdf
key: ${{ runner.os }}-tooling-${{ hashFiles('**/.tool-versions') }}
restore-keys: |
${{ runner.os }}-tooling-

- name: Install tooling using asdf
uses: asdf-vm/actions/install@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 # v3
with:
Expand Down
20 changes: 0 additions & 20 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: Cache asdf installation
id: cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: |
/home/runner/.asdf
key: ${{ runner.os }}-tooling-${{ hashFiles('**/.tool-versions') }}
restore-keys: |
${{ runner.os }}-tooling-

- name: Install tooling using asdf
uses: asdf-vm/actions/install@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 # v3
with:
Expand Down Expand Up @@ -215,16 +205,6 @@ jobs:
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: Cache asdf installation
id: cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: |
/home/runner/.asdf
key: ${{ runner.os }}-tooling-${{ hashFiles('**/.tool-versions') }}
restore-keys: |
${{ runner.os }}-tooling-

- name: Install tooling using asdf
uses: asdf-vm/actions/install@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 # v3
with:
Expand Down
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ eksctl 0.202.0

golang 1.23.5

jq 1.7.1

just 1.39.0

opentofu 1.9.0
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Consider installing Camunda 8 via [this guide](https://docs.camunda.io/docs/next

## Usage

### Example

Below is a simple example configuration for deploying both an EKS cluster, an Aurora PostgreSQL database and an OpenSearch domain.

See [AWS EKS Cluster inputs](./modules/eks-cluster/README.md#inputs), [AWS Aurora RDS inputs](./modules/aurora/README.md#inputs) and [AWS OpenSearch inputs](./modules/opensearch/README.md#inputs) for further configuration options and how they affect the cluster and database creation.
Expand Down
3 changes: 3 additions & 0 deletions modules/eks-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ module "eks_cluster" {
| [kubernetes_storage_class_v1.ebs_sc](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/storage_class_v1) | resource |
| [time_sleep.eks_cluster_warmup](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_eips.current_usage](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eips) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
| [aws_servicequotas_service_quota.elastic_ip_quota](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/servicequotas_service_quota) | data source |
| [aws_vpcs.current_vpcs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpcs) | data source |
## Inputs

| Name | Description | Type | Default | Required |
Expand Down
25 changes: 24 additions & 1 deletion modules/eks-cluster/vpc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@ locals {
]
}

data "aws_servicequotas_service_quota" "elastic_ip_quota" {
service_code = "ec2"
quota_code = "L-0263D0A3" # Quota code for Elastic IP addresses per region
}


data "aws_eips" "current_usage" {}

# Data source to check if the VPC exists
data "aws_vpcs" "current_vpcs" {
tags = {
Name = local.vpc_name
}
}

check "elastic_ip_quota_check" {

# Only check the condition when no existing vpc is there
assert {
condition = length(data.aws_vpcs.current_vpcs.ids) > 0 || (data.aws_servicequotas_service_quota.elastic_ip_quota.value - length(data.aws_eips.current_usage.public_ips)) >= length(local.azs)
error_message = "Not enough available Elastic IPs to cover all local availability zones (need: ${length(local.azs)}, have: ${(data.aws_servicequotas_service_quota.elastic_ip_quota.value - length(data.aws_eips.current_usage.public_ips))})."
}
}


module "vpc" {
source = "terraform-aws-modules/vpc/aws"
Expand Down Expand Up @@ -59,5 +83,4 @@ module "vpc" {
enable_flow_log = false
create_flow_log_cloudwatch_iam_role = false
create_flow_log_cloudwatch_log_group = false

}
Loading