diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 4841ee5..fab32b7 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.1.0 +current_version = 1.0.0 commit = True message = Bumps version to {new_version} tag = False diff --git a/.github/dependabot.yml b/.github/dependabot.yml index bb9ff6c..4a55019 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -10,3 +10,7 @@ updates: directory: / schedule: interval: weekly + - package-ecosystem: terraform + directory: / + schedule: + interval: weekly diff --git a/CHANGELOG.md b/CHANGELOG.md index e5f6e6c..aab7aca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,25 +1,13 @@ -## repo-template +## terraform-aws-tardigrade-resource-group 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.1.0 +### [1.0.0] (https://github.com/plus3it/terraform-aws-tardigrade-resource-group/releases/tag/1.0.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**: 2023.03.16 **Summary**: -* Initial release of capability +* Initial capability release, create an AWS resource group diff --git a/CHANGELOG.template.md b/CHANGELOG.template.md deleted file mode 100644 index 306af40..0000000 --- a/CHANGELOG.template.md +++ /dev/null @@ -1,15 +0,0 @@ -## {{ repo-name }} - -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/). - -### {{Major.Minor.Patch}} - -**Commit Delta**: {{ Link to compare changes with prior version }} - -**Released**: {{ YYYY.MM.DD }} - -**Summary**: - -* {{ Bulleted descriptions of enhancements, changes, or fixes }} diff --git a/LICENSE b/LICENSE index 598c4b8..7cd18c6 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2023 Maintainers of plus3it/repo-template + Copyright 2023 Maintainers of plus3it/terraform-aws-tardigrade-resource-group Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Makefile b/Makefile index 634033f..64ad505 100644 --- a/Makefile +++ b/Makefile @@ -1 +1,3 @@ +SHELL := /bin/bash + include $(shell test -f .tardigrade-ci || curl -sSL -o .tardigrade-ci "https://raw.githubusercontent.com/plus3it/tardigrade-ci/master/bootstrap/Makefile.bootstrap"; echo .tardigrade-ci) diff --git a/README.md b/README.md index ceff70c..9ceda16 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,27 @@ -# 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. 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 -5. Commit the changes and open a pull request + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Resources + +| Name | Type | +|------|------| + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [resource\_group](#input\_resource\_group) | Object of configuration attributes for the resource group |
object({| n/a | yes | + +## Outputs + +No outputs. + + diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..108c716 --- /dev/null +++ b/main.tf @@ -0,0 +1,9 @@ +resource "aws_resourcegroups_group" "this" { + name = var.resource_group.name + description = var.resource_group.description + + resource_query { + query = jsonencode(var.resource_group.resource_query.query) + type = var.resource_group.resource_query.type + } +} diff --git a/tests/test-resource-groups/main.tf b/tests/test-resource-groups/main.tf new file mode 100644 index 0000000..61de1ce --- /dev/null +++ b/tests/test-resource-groups/main.tf @@ -0,0 +1,24 @@ +module "resource_group" { + source = "../.." + resource_group = { + name = local.name + + resource_query = { + type = local.type + query = local.query + } + } +} + +locals { + name = "ec2_grouped_by_something" + type = "TAG_FILTERS_1_0" + query = { + ResourceTypeFilters = ["AWS::EC2::Instance", "AWS::S3::Bucket"] + TagFilters = [{ + Key = "some_tag_key" + Values = ["some_tag_value"] + } + ] + } +} diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..138a4e3 --- /dev/null +++ b/variables.tf @@ -0,0 +1,31 @@ +variable "resource_group" { + description = "Object of configuration attributes for the resource group" + type = object({ + name = string + description = optional(string) + + resource_query = object({ + type = optional(string, "TAG_FILTERS_1_0") + query = object({ + ResourceTypeFilters = optional(list(string), ["AWS::AllSupported"]) + TagFilters = list(object({ + Key = string, + Values = list(string) + })) + }) + }) + }) + + validation { + condition = lower(var.resource_group.name) != "aws" + error_message = "The resource_group.name must not begin with aws or AWS" + } + + validation { + condition = contains( + ["TAG_FILTERS_1_0", "CLOUDFORMATION_STACK_1_0"], + var.resource_group.resource_query.type + ) + error_message = "The resource_group.resource_query.type must be one of: TAG_FILTERS_1_O, CLOUDFORMATION_STACK_1_0" + } +}
name = string
description = optional(string)
resource_query = object({
type = optional(string, "TAG_FILTERS_1_0")
query = object({
ResourceTypeFilters = optional(list(string), ["AWS::AllSupported"])
TagFilters = list(object({
Key = string,
Values = list(string)
}))
})
})
})