Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

configure precommit ci #13

Merged
merged 5 commits into from
Dec 22, 2023
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
31 changes: 0 additions & 31 deletions .github/workflows/format-validate.yaml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
on:
pull_request:
push:
branches: [main]

jobs:
pre_commit:
name: Run pre-commit and commit any autocorrections
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.6.6
- name: Setup Terragrunt
uses: autero1/action-terragrunt@v1.1.0
with:
terragrunt_version: 0.54.8
# To avoid rate-limiting
token: ${{ secrets.GITHUB_TOKEN }}
- uses: terraform-linters/setup-tflint@v3
name: TFLint - Setup
with:
tflint_version: latest

- name: TFLint - Init
run: tflint --init
env:
# https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md#avoiding-rate-limiting
GITHUB_TOKEN: ${{ github.token }}
- name: TFLint - Show version
run: tflint --version
- uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Terraform Docs - Install
run: |
curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.17.0/terraform-docs-v0.17.0-$(uname)-amd64.tar.gz
tar -xzf terraform-docs.tar.gz -- terraform-docs
chmod +x terraform-docs
echo $PATH
mv terraform-docs /usr/local/bin/terraform-docs
terraform-docs --version
- uses: pre-commit/action@v3.0.0
- uses: pre-commit-ci/lite-action@v1.0.1
if: always()
18 changes: 15 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,30 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
args: ["--allow-multiple-documents"]
- id: check-added-large-files
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.77.0 # Get the latest from: https://github.com/antonbabenko/pre-commit-terraform/releases
rev: v1.85.0 # Get the latest from: https://github.com/antonbabenko/pre-commit-terraform/releases
hooks:
- id: terraform_fmt # args: ["--enable require-variable-braces,deprecate-which"]
- id: terraform_tflint
exclude: .*
args:
- "--args=--fix"
- id: terragrunt_fmt
- id: terraform_docs
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: [terraform_fmt, terraform_tflint, terragrunt_fmt, terraform_docs]
submodules: false
34 changes: 34 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# License

As a work of the [United States government](https://www.usa.gov/), this project
is in the public domain within the United States of America.

Additionally, we waive copyright and related rights in the work worldwide
through the CC0 1.0 Universal public domain dedication.

## CC0 1.0 Universal Summary

This is a human-readable summary of the [Legal Code (read the full
text)](https://creativecommons.org/publicdomain/zero/1.0/legalcode).

### No Copyright

The person who associated a work with this deed has dedicated the work to the
public domain by waiving all of their rights to the work worldwide under
copyright law, including all related and neighboring rights, to the extent
allowed by law.

You can copy, modify, distribute, and perform the work, even for commercial
purposes, all without asking permission.

### Other Information

In no way are the patent or trademark rights of any person affected by CC0, nor
are the rights that other persons may have in the work or in how the work is
used, such as publicity or privacy rights.

Unless expressly stated otherwise, the person who associated a work with this
deed makes no warranties about the work, and disclaims liability for all uses
of the work, to the fullest extent permitted by applicable law. When using or
citing the work, you should not imply endorsement by the author or the
affirmer.
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# batcave-tf-karpenter

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.2 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.61.0 |
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.11.0 |
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.10.0 |
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.1.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.61.0 |
| <a name="provider_helm"></a> [helm](#provider\_helm) | >= 2.11.0 |
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | >= 2.10.0 |
| <a name="provider_null"></a> [null](#provider\_null) | >= 3.1.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_iam_assumable_role_karpenter"></a> [iam\_assumable\_role\_karpenter](#module\_iam\_assumable\_role\_karpenter) | terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc | 4.7.0 |

## Resources

| Name | Type |
|------|------|
| [aws_iam_instance_profile.karpenter](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_instance_profile) | resource |
| [aws_iam_policy.karpenter_contoller](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
| [aws_iam_policy.ssm_managed_instance](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
| [aws_iam_role_policy_attachment.karpenter_contoller_policy_attachment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
| [aws_iam_role_policy_attachment.karpenter_ssm_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
| [helm_release.karpenter](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [kubernetes_manifest.eniconfig_subnets](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/manifest) | resource |
| [null_resource.rotate_nodes_after_eniconfig_creation](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [aws_eks_cluster.cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster) | data source |
| [aws_eks_cluster_auth.cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster_auth) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_cluster_endpoint"></a> [cluster\_endpoint](#input\_cluster\_endpoint) | n/a | `string` | `""` | no |
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | n/a | `string` | n/a | yes |
| <a name="input_helm_create_namespace"></a> [helm\_create\_namespace](#input\_helm\_create\_namespace) | n/a | `bool` | `true` | no |
| <a name="input_helm_namespace"></a> [helm\_namespace](#input\_helm\_namespace) | n/a | `string` | `"karpenter"` | no |
| <a name="input_iam_path"></a> [iam\_path](#input\_iam\_path) | n/a | `string` | `"/delegatedadmin/developer/"` | no |
| <a name="input_permissions_boundary"></a> [permissions\_boundary](#input\_permissions\_boundary) | n/a | `string` | `"arn:aws:iam::373346310182:policy/cms-cloud-admin/developer-boundary-policy"` | no |
| <a name="input_provider_url"></a> [provider\_url](#input\_provider\_url) | n/a | `string` | `""` | no |
| <a name="input_rotate_nodes_after_eniconfig_creation"></a> [rotate\_nodes\_after\_eniconfig\_creation](#input\_rotate\_nodes\_after\_eniconfig\_creation) | n/a | `bool` | `true` | no |
| <a name="input_vpc_eni_subnets"></a> [vpc\_eni\_subnets](#input\_vpc\_eni\_subnets) | n/a | `map(any)` | n/a | yes |
| <a name="input_worker_iam_role_name"></a> [worker\_iam\_role\_name](#input\_worker\_iam\_role\_name) | n/a | `string` | n/a | yes |
| <a name="input_worker_security_group_id"></a> [worker\_security\_group\_id](#input\_worker\_security\_group\_id) | n/a | `string` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_hr_manifest"></a> [hr\_manifest](#output\_hr\_manifest) | The rendered manifest of the release as JSON |
| <a name="output_karpenter_iam"></a> [karpenter\_iam](#output\_karpenter\_iam) | n/a |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
17 changes: 17 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Security and Responsible Disclosure Policy

*Submit a vulnerability:* Unfortunately, we cannot accept secure submissions via
email or via GitHub Issues. Please use our website to submit vulnerabilities at
[https://hhs.responsibledisclosure.com](https://hhs.responsibledisclosure.com).
HHS maintains an acknowledgements page to recognize your efforts on behalf of
the American public, but you are also welcome to submit anonymously.

Review the HHS Disclosure Policy and websites in scope:
[https://www.hhs.gov/vulnerability-disclosure-policy/index.html](https://www.hhs.gov/vulnerability-disclosure-policy/index.html).

This policy describes *what systems and types of research* are covered under this
policy, *how to send* us vulnerability reports, and *how long* we ask security
researchers to wait before publicly disclosing vulnerabilities.

If you have other cybersecurity related questions, please contact us at
[csirc@hhs.gov.](mailto:csirc@hhs.gov).
4 changes: 2 additions & 2 deletions eniconfig.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ resource "kubernetes_manifest" "eniconfig_subnets" {
"apiVersion" = "crd.k8s.amazonaws.com/v1alpha1"
"kind" = "ENIConfig"
"metadata" = {
"name" = "${each.key}"
"name" = each.key
}
"spec" = {
"subnet" = "eni-${each.value}"
"securityGroups" = [
"${var.worker_security_group_id}"
var.worker_security_group_id
]
}
}
Expand Down
5 changes: 2 additions & 3 deletions karpenter.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ data "aws_eks_cluster" "cluster" {
provider "helm" {
kubernetes {
host = data.aws_eks_cluster.cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority[0].data)
exec {
api_version = "client.authentication.k8s.io/v1alpha1"
args = ["eks", "get-token", "--cluster-name", data.aws_eks_cluster.cluster.name]
Expand All @@ -27,7 +27,7 @@ resource "helm_release" "karpenter" {
version = "0.6.1"

values = [
"${file("values.yaml")}"
file("values.yaml")
]
set {
name = "serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn"
Expand All @@ -44,4 +44,3 @@ resource "helm_release" "karpenter" {
value = var.cluster_endpoint
}
}

2 changes: 1 addition & 1 deletion karpenter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# subnetSelector:
# ContainerSubnet: "true"
# ttlSecondsAfterEmpty: 30

---
apiVersion: karpenter.sh/v1alpha5
kind: Provisioner
Expand Down
21 changes: 21 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.61.0"
}
null = {
source = "hashicorp/null"
version = ">= 3.1.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.10.0"
}
helm = {
source = "hashicorp/helm"
version = ">= 2.11.0"
}
}
required_version = ">= 1.2"
}
1 change: 0 additions & 1 deletion output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ output "hr_manifest" {
value = helm_release.karpenter
sensitive = true
}

2 changes: 1 addition & 1 deletion test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ spec:
kubernetes.io/cluster/batcave-dev: 'shared'
securityGroupSelector:
Name: sg-0ae8da89426d04ac6
ttlSecondsAfterEmpty: 30
ttlSecondsAfterEmpty: 30
2 changes: 1 addition & 1 deletion test/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ spec:
image: public.ecr.aws/eks-distro/kubernetes/pause:3.2
resources:
requests:
cpu: 1
cpu: 1
2 changes: 1 addition & 1 deletion values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ webhook:
tolerations:
- key: "CriticalAddonsOnly"
operator: "Exists"
effect: "NoSchedule"
effect: "NoSchedule"
14 changes: 9 additions & 5 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
variable "cluster_name" {}
variable "cluster_name" {
type = string
}
variable "provider_url" {
default = ""
type = string
}


### Karpenter IAM variables

variable "worker_iam_role_name" {
default = ""
type = string
}

variable "iam_path" {
default = "/delegatedadmin/developer/"
type = string
}

variable "permissions_boundary" {
default = "arn:aws:iam::373346310182:policy/cms-cloud-admin/developer-boundary-policy"
type = string
}


### Helm variables

variable "helm_namespace" {
default = "karpenter"
type = string
}
variable "helm_create_namespace" {
type = bool
default = true
}
variable "helm_name" {
default = "karpenter"
}
variable "cluster_endpoint" {
default = ""
type = string
}

variable "vpc_eni_subnets" {
Expand Down
Loading