Skip to content

Commit

Permalink
Merge pull request #1 from lorengordon/init
Browse files Browse the repository at this point in the history
Provides initial capability for managing an ec2 prefix list and its entries
  • Loading branch information
lorengordon authored Nov 13, 2024
2 parents 10c6b07 + b7d9917 commit 1a2c7b9
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.2.1
current_version = 1.0.0
commit = True
message = Bumps version to {new_version}
tag = False
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ jobs:
uses: plus3it/actions-workflows/.github/workflows/release.yml@00bdf2c02c2bb252dc7ba7f74816ac8359aa6693
secrets:
release-token: ${{ secrets.GH_RELEASES_TOKEN }}
with:
mockstacktest-enable: false
35 changes: 4 additions & 31 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,13 @@
## repo-template
## terraform-aws-tardigrade-ec2-managed-prefix-list

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

### [1.2.1] (https://github.com/plus3it/repo-template/releases/tag/1.2.1)
### [1.0.0](https://github.com/plus3it/terraform-aws-tardigrade-ec2-managed-prefix-list/releases/tag/1.0.0)

**Summary**:

* Updated README.md to include config settings for github
* Updated LICENSE copyright year

### [1.2.0] (https://github.com/plus3it/repo-template/releases/tag/1.2.0)

**Summary**:

* Updated SHA value for Github Actions Workflows
* Updated CHANGELOG.template.md file
* Added Master branch in release workflow logic to make migration to Github Actions more efficient

### 1.1.0

**Commit Delta**: N/A

**Released**: 2023.01.27

**Summary**:

* Updated workflow files to be consumable and reusable, and now points to actions-workflows repo

### 1.0.0

**Commit Delta**: N/A

**Released**: 2023.01.10
**Released**: 2024.11.11

**Summary**:

* Initial release of capability
* Initial release of capability to manage an EC2 prefix list and its rules
13 changes: 0 additions & 13 deletions CHANGELOG.template.md

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2024 Maintainers of plus3it/repo-template
Copyright 2024 Maintainers of plus3it/terraform-aws-tardigrade-ec2-managed-prefix-list

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
86 changes: 34 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,34 @@
# repo-template
Generic repo template for Plus3IT repositories

To use this template:

1. Select the green "Use this template" button, or [click here](https://github.com/plus3it/repo-template/generate).
2. Select the repo Owner, give the repo a name, enter a description, select Public or Private, and click "Create repository from template".
3. Clone the repository and create a new branch.
4. Configure the following settings on your new repo.
* `GENERAL`
* `Features`
* Turn off Wikis, Sponsorships, Discussions, and Projects
* `Pull Requests`
* Turn off Squash Merging
* Turn off Rebase Merging
* Turn on Allow Auto-Merge
* Turn on Automatically delete head branches
* `Pushes`
* Limit how many branches can be updated in a single push: 2
* `COLLABORATORS and TEAMS`
* `Manage Access`
* Add relevant team roles, for example
* `tardigrade-admins` (Admin)
* `terraform` (Write)
* `releasebot` (Write)
* `Branches`
* `Create Branch Protection rule` for `main`
* Turn on Require pull request before merging
* Turn on Require approvals
* Turn on Dismiss stale pull requests...
* `Required Status Checks`
* As relevant to projects, for example
* WIP
* lint/actionlint
* lint/tardigradelint
* test / mockstacktest
* Turn on Do not allow bypassing the above settings
5. Edit the following files to customize them for the new repository:
* `LICENSE`
* Near the end of the file, edit the date and change the repository name
* `CHANGELOG.template.md`
* Rename to `CHANGELOG.md`, replacing the repo-template changelog
* Edit templated items for the new repo
* `.bumpversion.cfg`
* Edit the version number for the new repo, ask team if not sure what to
start with
* `README.md`
* Replace contents for the new repo
* `.github/`
* Inspect dependabot and workflow files in case changes are needed for
the new repo
6. Commit the changes and open a pull request
# terraform-aws-tardigrade-ec2-managed-prefix-list

Terraform module for managing an EC2 Prefix List and its entries.

<!-- BEGIN TFDOCS -->
## Requirements

No requirements.

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |

## Resources

| Name | Type |
|------|------|

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_ec2_managed_prefix_list"></a> [ec2\_managed\_prefix\_list](#input\_ec2\_managed\_prefix\_list) | Object of attributes for the EC2 managed prefix list | <pre>object({<br> name = string<br> address_family = optional(string, "IPv4")<br> max_entries = optional(number)<br> tags = optional(map(string), {})<br><br> entries = optional(list(object({<br> name = string<br> cidr = string<br> description = optional(string)<br> })), [])<br> })</pre> | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_ec2_managed_prefix_list"></a> [ec2\_managed\_prefix\_list](#output\_ec2\_managed\_prefix\_list) | Object of attributes for the managed prefix list |
| <a name="output_ec2_managed_prefix_list_entries"></a> [ec2\_managed\_prefix\_list\_entries](#output\_ec2\_managed\_prefix\_list\_entries) | Object of attributes for the managed prefix list entries |

<!-- END TFDOCS -->
15 changes: 15 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "aws_ec2_managed_prefix_list" "this" {
name = var.ec2_managed_prefix_list.name

address_family = var.ec2_managed_prefix_list.address_family
max_entries = coalesce(var.ec2_managed_prefix_list.max_entries, max(length(var.ec2_managed_prefix_list.entries), 1))
tags = var.ec2_managed_prefix_list.tags
}

resource "aws_ec2_managed_prefix_list_entry" "this" {
for_each = { for prefix_list in var.ec2_managed_prefix_list.entries : prefix_list.name => prefix_list }

cidr = each.value.cidr
description = coalesce(each.value.description, each.value.name)
prefix_list_id = aws_ec2_managed_prefix_list.this.id
}
9 changes: 9 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
output "ec2_managed_prefix_list" {
description = "Object of attributes for the managed prefix list"
value = aws_ec2_managed_prefix_list.this
}

output "ec2_managed_prefix_list_entries" {
description = "Object of attributes for the managed prefix list entries"
value = aws_ec2_managed_prefix_list_entry.this
}
31 changes: 31 additions & 0 deletions tests/all-inputs/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module "ec2_managed_prefix_list" {
source = "../.."

ec2_managed_prefix_list = {
name = "tardigrade-test-prefix-list-${local.id}"
address_family = "IPv4"
max_entries = 5
tags = {
Name = "tardigrade-test-prefix-list-${local.id}"
}

entries = [
{
name = "tardigrade-test-prefix-list-entry-${local.id}-1"
cidr = "10.0.0.0/16"
description = "tardigrade-test-prefix-list-entry-${local.id}-1"
},
]
}
}

data "terraform_remote_state" "prereq" {
backend = "local"
config = {
path = "prereq/terraform.tfstate"
}
}

locals {
id = data.terraform_remote_state.prereq.outputs.test_id.result
}
10 changes: 10 additions & 0 deletions tests/all-inputs/prereq/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "random_string" "this" {
length = 6
upper = false
special = false
numeric = false
}

output "test_id" {
value = random_string.this
}
18 changes: 18 additions & 0 deletions tests/defaults/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module "ec2_managed_prefix_list" {
source = "../.."

ec2_managed_prefix_list = {
name = "tardigrade-test-prefix-list-${random_string.this.result}"
}
}

resource "random_string" "this" {
length = 6
upper = false
special = false
numeric = false
}

locals {
id = random_string.this.result
}
15 changes: 15 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
variable "ec2_managed_prefix_list" {
description = "Object of attributes for the EC2 managed prefix list"
type = object({
name = string
address_family = optional(string, "IPv4")
max_entries = optional(number)
tags = optional(map(string), {})

entries = optional(list(object({
name = string
cidr = string
description = optional(string)
})), [])
})
}

0 comments on commit 1a2c7b9

Please sign in to comment.