-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: initial move from foundation to terraform only repo
- Loading branch information
0 parents
commit a64d3be
Showing
17 changed files
with
743 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: lint-pr-title | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, reopened, synchronize] | ||
|
||
jobs: | ||
pr-lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: morrisoncole/[email protected] | ||
with: | ||
# Note: if you have branch protection rules enabled, the `GITHUB_TOKEN` permissions | ||
# won't cover dismissing reviews. Your options are to pass in a custom token | ||
# (perhaps by creating some sort of 'service' user and creating a personal access | ||
# token with the correct permissions) or to turn off `on-failed-regex-request-changes` | ||
# and use action failure to prevent merges instead (with | ||
# `on-failed-regex-fail-action: true`). See: | ||
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token | ||
# https://docs.github.com/en/rest/pulls/reviews#dismiss-a-review-for-a-pull-request | ||
repo-token: "${{ secrets.GITHUB_TOKEN }}" | ||
title-regex: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)' | ||
on-failed-regex-fail-action: true | ||
on-failed-regex-create-review: false | ||
on-failed-regex-request-changes: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: pre-commit | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: install pre-commit | ||
run: pip install pre-commit | ||
|
||
- name: Terraform | ||
uses: hashicorp/setup-terraform@v3 | ||
with: | ||
terraform_version: "1.5.7" | ||
|
||
- name: install hcledit | ||
run: | | ||
curl -sSLo ./hcledit.tar.gz https://github.com/minamijoyo/hcledit/releases/download/v0.2.10/hcledit_0.2.10_linux_amd64.tar.gz | ||
tar -xzf hcledit.tar.gz | ||
chmod +x hcledit | ||
mv hcledit /usr/local/bin/hcledit | ||
- name: install tf-lint | ||
run: curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash | ||
|
||
- name: install tf-docs | ||
run: | | ||
curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.17.0/terraform-docs-v0.17.0-linux-amd64.tar.gz | ||
tar -xzf terraform-docs.tar.gz | ||
chmod +x terraform-docs | ||
mv terraform-docs /usr/local/bin/terraform-docs | ||
- name: pre-commit | ||
run: pre-commit run --all-files --show-diff-on-failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: release-notes | ||
|
||
on: | ||
push: | ||
tags: | ||
- v[0-9]+.[0-9]+.[0-9]+ | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Update CHANGELOG | ||
id: changelog | ||
uses: requarks/changelog-action@v1 | ||
with: | ||
token: ${{ github.token }} | ||
tag: ${{ github.ref_name }} | ||
|
||
- name: Create Release | ||
uses: ncipollo/[email protected] | ||
with: | ||
allowUpdates: true | ||
draft: false | ||
makeLatest: true | ||
name: ${{ github.ref_name }} | ||
body: ${{ steps.changelog.outputs.changes }} | ||
token: ${{ github.token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Local .terraform directories | ||
**/.terraform/* | ||
|
||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
|
||
# Crash log files | ||
crash.log | ||
crash.*.log | ||
|
||
# Exclude all .tfvars files, which are likely to contain sensitive data, such as | ||
# password, private keys, and other secrets. These should not be part of version | ||
# control as they are data points which are potentially sensitive and subject | ||
# to change depending on the environment. | ||
*.tfvars | ||
*.tfvars.json | ||
|
||
# Ignore override files as they are usually used to override resources locally and so | ||
# are not checked in | ||
override.tf | ||
override.tf.json | ||
*_override.tf | ||
*_override.tf.json | ||
|
||
# Include override files you do wish to add to version control using negated pattern | ||
# !example_override.tf | ||
|
||
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan | ||
# example: *tfplan* | ||
|
||
# Ignore CLI configuration files | ||
.terraformrc | ||
terraform.rc | ||
|
||
.idea/* | ||
|
||
# Devenv | ||
.devenv* | ||
devenv.local.nix | ||
.direnv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v5.0.0 | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: forbid-submodules | ||
- repo: https://github.com/adrienverge/yamllint | ||
rev: v1.35.1 | ||
hooks: | ||
- id: yamllint | ||
args: [--strict, -c=.yamllint] | ||
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook | ||
rev: v9.18.0 | ||
hooks: | ||
- id: commitlint | ||
stages: [commit-msg] | ||
additional_dependencies: ['@commitlint/config-conventional'] | ||
- repo: https://github.com/antonbabenko/pre-commit-terraform | ||
rev: v1.96.1 | ||
hooks: | ||
- id: terraform_wrapper_module_for_each | ||
- id: terraform_tflint | ||
args: | ||
- '--args=--only=terraform_deprecated_interpolation' | ||
- '--args=--only=terraform_deprecated_index' | ||
- '--args=--only=terraform_unused_declarations' | ||
- '--args=--only=terraform_comment_syntax' | ||
- '--args=--only=terraform_documented_outputs' | ||
- '--args=--only=terraform_documented_variables' | ||
- '--args=--only=terraform_typed_variables' | ||
- '--args=--only=terraform_module_pinned_source' | ||
- '--args=--only=terraform_naming_convention' | ||
- '--args=--only=terraform_required_version' | ||
- '--args=--only=terraform_required_providers' | ||
- '--args=--only=terraform_standard_module_structure' | ||
- '--args=--only=terraform_workspace_remote' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
plugin "aws" { | ||
enabled = true | ||
version = "0.36.0" | ||
source = "github.com/terraform-linters/tflint-ruleset-aws" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
extends: relaxed | ||
|
||
rules: | ||
line-length: disable | ||
commas: disable | ||
indentation: | ||
spaces: 2 | ||
indent-sequences: whatever | ||
|
||
ignore: | | ||
*.terraform/ | ||
gitops/base-install/cert-manager/create-issuer/templates/create-issuer.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 | | ||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.45.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.45.0 | | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_cert_manager_irsa_role"></a> [cert\_manager\_irsa\_role](#module\_cert\_manager\_irsa\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | 5.51.0 | | ||
| <a name="module_ebs_csi_driver_irsa_role"></a> [ebs\_csi\_driver\_irsa\_role](#module\_ebs\_csi\_driver\_irsa\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | 5.51.0 | | ||
| <a name="module_eks"></a> [eks](#module\_eks) | terraform-aws-modules/eks/aws | 20.31.6 | | ||
| <a name="module_external_dns_irsa_role"></a> [external\_dns\_irsa\_role](#module\_external\_dns\_irsa\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | 5.51.0 | | ||
| <a name="module_karpenter"></a> [karpenter](#module\_karpenter) | terraform-aws-modules/eks/aws//modules/karpenter | 20.31.6 | | ||
| <a name="module_load_balancer_controller_irsa_role"></a> [load\_balancer\_controller\_irsa\_role](#module\_load\_balancer\_controller\_irsa\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | 5.51.0 | | ||
| <a name="module_s3_csi"></a> [s3\_csi](#module\_s3\_csi) | terraform-aws-modules/s3-bucket/aws | 4.3.0 | | ||
| <a name="module_s3_driver_irsa_role"></a> [s3\_driver\_irsa\_role](#module\_s3\_driver\_irsa\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | 5.51.0 | | ||
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | 5.17.0 | | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [aws_vpc_endpoint.eks_vpc_endpoints](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_endpoint) | resource | | ||
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source | | ||
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_extra_access_entries"></a> [extra\_access\_entries](#input\_extra\_access\_entries) | EKS access entries needed by IAM roles interacting with this cluster | <pre>list(object({<br/> principal_arn = string<br/> kubernetes_groups = optional(list(string))<br/> policy_arn = string<br/> access_scope_type = string<br/> access_scope_namespaces = optional(list(string))<br/> }))</pre> | `[]` | no | | ||
| <a name="input_initial_instance_types"></a> [initial\_instance\_types](#input\_initial\_instance\_types) | instance types of the initial managed node group | `list(string)` | n/a | yes | | ||
| <a name="input_initial_node_desired_size"></a> [initial\_node\_desired\_size](#input\_initial\_node\_desired\_size) | desired size of the initial managed node group | `number` | `3` | no | | ||
| <a name="input_initial_node_labels"></a> [initial\_node\_labels](#input\_initial\_node\_labels) | labels for the initial managed node group | `map(string)` | <pre>{<br/> "kube-ovn/role": "master"<br/>}</pre> | no | | ||
| <a name="input_initial_node_max_size"></a> [initial\_node\_max\_size](#input\_initial\_node\_max\_size) | max size of the initial managed node group | `number` | `6` | no | | ||
| <a name="input_initial_node_min_size"></a> [initial\_node\_min\_size](#input\_initial\_node\_min\_size) | minimum size of the initial managed node group | `number` | `2` | no | | ||
| <a name="input_initial_node_taints"></a> [initial\_node\_taints](#input\_initial\_node\_taints) | taints for the initial managed node group | `list(object({ key = string, value = string, effect = string }))` | <pre>[<br/> {<br/> "effect": "NO_SCHEDULE",<br/> "key": "CriticalAddonsOnly",<br/> "value": "true"<br/> },<br/> {<br/> "effect": "NO_SCHEDULE",<br/> "key": "nidhogg.uswitch.com/kube-system.kube-multus-ds",<br/> "value": "true"<br/> }<br/>]</pre> | no | | ||
| <a name="input_s3_csi_driver_bucket_arns"></a> [s3\_csi\_driver\_bucket\_arns](#input\_s3\_csi\_driver\_bucket\_arns) | existing buckets the s3 CSI driver should have access to | `list(string)` | `[]` | no | | ||
| <a name="input_s3_csi_driver_create_bucket"></a> [s3\_csi\_driver\_create\_bucket](#input\_s3\_csi\_driver\_create\_bucket) | create a new bucket for use with the s3 CSI driver | `bool` | `true` | no | | ||
| <a name="input_stack_admin_arns"></a> [stack\_admin\_arns](#input\_stack\_admin\_arns) | arn to the roles for the cluster admins role | `list(string)` | `[]` | no | | ||
| <a name="input_stack_ci_admin_arn"></a> [stack\_ci\_admin\_arn](#input\_stack\_ci\_admin\_arn) | arn to the ci role | `string` | n/a | yes | | ||
| <a name="input_stack_ci_ro_arn"></a> [stack\_ci\_ro\_arn](#input\_stack\_ci\_ro\_arn) | arn to the ci role for planning on PRs | `string` | n/a | yes | | ||
| <a name="input_stack_create"></a> [stack\_create](#input\_stack\_create) | should resources be created | `bool` | `true` | no | | ||
| <a name="input_stack_name"></a> [stack\_name](#input\_stack\_name) | Name of the stack | `string` | `"foundation-stack"` | no | | ||
| <a name="input_stack_ro_arns"></a> [stack\_ro\_arns](#input\_stack\_ro\_arns) | arn to the roles for the cluster read only role | `list(string)` | `[]` | no | | ||
| <a name="input_stack_tags"></a> [stack\_tags](#input\_stack\_tags) | tags to be added to the stack, should at least have Owner and Environment | `map(any)` | <pre>{<br/> "Environment": "prod",<br/> "Owner": "pelotech"<br/>}</pre> | no | | ||
| <a name="input_stack_vpc_block"></a> [stack\_vpc\_block](#input\_stack\_vpc\_block) | Variables for defining the vpc for the stack | <pre>object({<br/> cidr = string<br/> azs = list(string)<br/> private_subnets = list(string)<br/> public_subnets = list(string)<br/> database_subnets = list(string)<br/> })</pre> | <pre>{<br/> "azs": [<br/> "us-west-2a",<br/> "us-west-2b",<br/> "us-west-2c"<br/> ],<br/> "cidr": "172.16.0.0/16",<br/> "database_subnets": [<br/> "172.16.200.0/24",<br/> "172.16.201.0/24",<br/> "172.16.202.0/24"<br/> ],<br/> "private_subnets": [<br/> "172.16.0.0/24",<br/> "172.16.1.0/24",<br/> "172.16.2.0/24"<br/> ],<br/> "public_subnets": [<br/> "172.16.100.0/24",<br/> "172.16.101.0/24",<br/> "172.16.102.0/24"<br/> ]<br/>}</pre> | no | | ||
| <a name="input_vpc_endpoints"></a> [vpc\_endpoints](#input\_vpc\_endpoints) | vpc endpoints within the cluster vpc network | `list(string)` | `[]` | no | | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
<!-- END_TF_DOCS --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: backstage.io/v1alpha1 | ||
kind: Component | ||
metadata: | ||
name: terraform-foundation-aws-stack | ||
description: Terraform modules to bootstrap k8s cluster in aws | ||
tags: | ||
- terraform | ||
- k8s | ||
annotations: | ||
github.com/project-slug: pelotech/terraform-foundation-aws-stack | ||
backstage.io/techdocs-ref: dir:. | ||
spec: | ||
type: infrastructure | ||
lifecycle: production | ||
owner: group:pelotech/leads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {extends: ['@commitlint/config-conventional']}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Cleanup | ||
|
||
This is the location to be able to hunt down most of the various resources which are created by the clusters components | ||
|
||
## Karpenter | ||
* Search for tags with `karpenter.sh/managed-by` = `{cluster-name}` | ||
|
||
## ALB/Cluster - | ||
### Security groups | ||
* Tags `elbv2.k8s.aws/cluster` = `{cluster-name}` | ||
* Tags `aws:eks:cluster-name` = `{cluster-name}` | ||
### Load Balancers | ||
* Tags `elbv2.k8s.aws/cluster` = `{cluster-name}` | ||
### Target Groups | ||
* Tags `elbv2.k8s.aws/cluster` = `{cluster-name}` | ||
|
||
## EBS | ||
### Volumes | ||
* Tags `ebs.csi.aws.com/cluster` = `true` | ||
* Tags `kubernetes.io/cluster/{cluster-name}` = `owned` | ||
* Tags `KubernetesCluster` = `{cluster-name}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
![pre-commit](https://github.com/pelotech/terraform-foundation-aws-stack/actions/workflows/pre-commit.yaml/badge.svg) | ||
|
||
# Foundation - Pelotech's GitOps K8s Cluster | ||
This is the terraform module that helps bootstrap foundation in AWS |
Oops, something went wrong.