diff --git a/.chglog/CHANGELOG.tpl.md b/.chglog/CHANGELOG.tpl.md deleted file mode 100644 index 687d702..0000000 --- a/.chglog/CHANGELOG.tpl.md +++ /dev/null @@ -1,111 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. - -{{ if .Versions -}} - -## [Unreleased] -{{ if .Unreleased.CommitGroups -}} -{{ range .Unreleased.CommitGroups -}} -### {{ .Title }} -{{ range .Commits -}} -{{/* SKIPPING RULES - START */ -}} -{{- if not (hasPrefix .Subject "Updated CHANGELOG") -}} -{{- if not (contains .Subject "[ci skip]") -}} -{{- if not (contains .Subject "[skip ci]") -}} -{{- if not (hasPrefix .Subject "Merge pull request ") -}} -{{- if not (hasPrefix .Subject "Added CHANGELOG") -}} -{{- /* SKIPPING RULES - END */ -}} -- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} -{{/* SKIPPING RULES - START */ -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{/* SKIPPING RULES - END */ -}} -{{ end }} -{{ end -}} -{{ else }} -{{ range .Unreleased.Commits -}} -{{/* SKIPPING RULES - START */ -}} -{{- if not (hasPrefix .Subject "Updated CHANGELOG") -}} -{{- if not (contains .Subject "[ci skip]") -}} -{{- if not (contains .Subject "[skip ci]") -}} -{{- if not (hasPrefix .Subject "Merge pull request ") -}} -{{- if not (hasPrefix .Subject "Added CHANGELOG") -}} -{{- /* SKIPPING RULES - END */ -}} -- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} -{{/* SKIPPING RULES - START */ -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{/* SKIPPING RULES - END */ -}} -{{ end }} -{{ end -}} -{{ end -}} - -{{ range .Versions }} - -## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }} -{{ if .CommitGroups -}} -{{ range .CommitGroups -}} -### {{ .Title }} -{{ range .Commits -}} -{{/* SKIPPING RULES - START */ -}} -{{- if not (hasPrefix .Subject "Updated CHANGELOG") -}} -{{- if not (contains .Subject "[ci skip]") -}} -{{- if not (contains .Subject "[skip ci]") -}} -{{- if not (hasPrefix .Subject "Merge pull request ") -}} -{{- if not (hasPrefix .Subject "Added CHANGELOG") -}} -{{- /* SKIPPING RULES - END */ -}} -- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} -{{/* SKIPPING RULES - START */ -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{/* SKIPPING RULES - END */ -}} -{{ end }} -{{ end -}} -{{ else }} -{{ range .Commits -}} -{{/* SKIPPING RULES - START */ -}} -{{- if not (hasPrefix .Subject "Updated CHANGELOG") -}} -{{- if not (contains .Subject "[ci skip]") -}} -{{- if not (contains .Subject "[skip ci]") -}} -{{- if not (hasPrefix .Subject "Merge pull request ") -}} -{{- if not (hasPrefix .Subject "Added CHANGELOG") -}} -{{- /* SKIPPING RULES - END */ -}} -- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} -{{/* SKIPPING RULES - START */ -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{ end -}} -{{/* SKIPPING RULES - END */ -}} -{{ end }} -{{ end -}} - -{{- if .NoteGroups -}} -{{ range .NoteGroups -}} -### {{ .Title }} -{{ range .Notes }} -{{ .Body }} -{{ end }} -{{ end -}} -{{ end -}} -{{ end -}} - -{{- if .Versions }} -[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD -{{ range .Versions -}} -{{ if .Tag.Previous -}} -[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }} -{{ end -}} -{{ end -}} -{{ end -}} diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 7b66fb6..0000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,21 +0,0 @@ -# I have issues - -## I'm submitting a - -* [ ] bug report -* [ ] feature request -* [ ] support request - -## What is the current behavior - -## If this is a bug, how to reproduce? Please include a code sample - -## What's the expected behavior - -## Environment - -* Affected module version: -* OS: -* Terraform version: - -## Other relevant info diff --git a/.github/ISSUE_TEMPLATE/custom.md b/.github/ISSUE_TEMPLATE/custom.md deleted file mode 100644 index 0767249..0000000 --- a/.github/ISSUE_TEMPLATE/custom.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -name: Custom issue template -about: Describe this issue template's purpose here. - ---- - -# I'm having issues... - -## I'm submitting a: - -* [ ] bug report -* [ ] feature request -* [ ] support request -* [ ] thank you! - -## What is the current behavior? - - -## If this is a bug, how to reproduce? Please include a code sample - - -## What's the expected behavior - - -## Environment - -* Affected module version: -* OS: -* Terraform version: - -## Other relevant info diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6790943..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,13 +0,0 @@ -# PR o'clock - -## Description - -Please explain the changes you made here and link to any relevant issues. - -### Checklist - -- [ ] `terraform fmt` and `terraform validate` both work from the root and `examples/ebs_optimized_test_fixture` directories (look in CI for an example) -- [ ] Tests for the changes have been added and passing (for bug fixes/features) -- [ ] Test results are pasted in this PR (in lieu of CI) -- [ ] Docs have been added/updated (for bug fixes/features) -- [ ] Any breaking changes are noted in the description above diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..b8f1b8a --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,78 @@ +name: Pre-Commit + +on: + pull_request: + branches: + - main + - master + +env: + TERRAFORM_DOCS_VERSION: v0.16.0 + +jobs: + collectInputs: + name: Collect workflow inputs + runs-on: ubuntu-latest + outputs: + directories: ${{ steps.dirs.outputs.directories }} + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Get root directories + id: dirs + uses: clowdhaus/terraform-composite-actions/directories@v1.3.0 + + preCommitMinVersions: + name: Min TF pre-commit + needs: collectInputs + runs-on: ubuntu-latest + strategy: + matrix: + directory: ${{ fromJson(needs.collectInputs.outputs.directories) }} + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Terraform min/max versions + id: minMax + uses: clowdhaus/terraform-min-max@v1.0.3 + with: + directory: ${{ matrix.directory }} + + - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} + # Run only validate pre-commit check on min version supported + if: ${{ matrix.directory != '.' }} + uses: clowdhaus/terraform-composite-actions/pre-commit@v1.3.0 + with: + terraform-version: ${{ steps.minMax.outputs.minVersion }} + args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*' + + - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} + # Run only validate pre-commit check on min version supported + if: ${{ matrix.directory == '.' }} + uses: clowdhaus/terraform-composite-actions/pre-commit@v1.3.0 + with: + terraform-version: ${{ steps.minMax.outputs.minVersion }} + args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)' + + preCommitMaxVersion: + name: Max TF pre-commit + runs-on: ubuntu-latest + needs: collectInputs + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{github.event.pull_request.head.repo.full_name}} + + - name: Terraform min/max versions + id: minMax + uses: clowdhaus/terraform-min-max@v1.0.3 + + - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }} + uses: clowdhaus/terraform-composite-actions/pre-commit@v1.3.0 + with: + terraform-version: ${{ steps.minMax.outputs.maxVersion }} + terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..141937d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +name: Release + +on: + workflow_dispatch: + push: + branches: + - main + - master + paths: + - '**/*.py' + - '**/*.tf' + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Release + uses: cycjimmy/semantic-release-action@v2 + with: + semantic_version: 18.0.0 + extra_plugins: | + @semantic-release/changelog@6.0.0 + @semantic-release/git@10.0.0 + env: + GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }} diff --git a/.gitignore b/.gitignore index 4fa2920..397af32 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,29 @@ -.terraform -terraform.tfstate -*.tfstate* -terraform.tfvars +# Local .terraform directories +**/.terraform/* + +# Terraform lockfile +.terraform.lock.hcl + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log + +# Exclude all .tfvars files, which are likely to contain sentitive 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 + +# 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 + +# Ignore CLI configuration files +.terraformrc +terraform.rc diff --git a/.kitchen.yml b/.kitchen.yml deleted file mode 100644 index ef5a82f..0000000 --- a/.kitchen.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -driver: - name: terraform - root_module_directory: examples/ebs_optimized_test_fixture - -provisioner: - name: terraform - -platforms: -- name: aws - -verifier: - name: terraform - -suites: - - - name: default - verifier: - groups: - - - name: default - attributes: - supported: supported - unsupported: unsupported - unknown_type_result: unknown - ebs_optimized_instance_id: ebs_optimized_instance_id - not_ebs_optimized_instance_id: not_ebs_optimized_instance_id - controls: - - ebs_optimized - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0285452..b0e03fc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,28 @@ repos: - - repo: git://github.com/antonbabenko/pre-commit-terraform - rev: v1.27.0 + - repo: https://github.com/antonbabenko/pre-commit-terraform + rev: v1.58.0 hooks: - id: terraform_fmt + - id: terraform_validate - id: terraform_docs - - repo: git://github.com/pre-commit/pre-commit-hooks - rev: v2.5.0 + args: + - '--args=--lockfile=false' + - 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' + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 hooks: - id: check-merge-conflict diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..6e39031 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,36 @@ +{ + "branches": [ + "main", + "master" + ], + "ci": false, + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + [ + "@semantic-release/github", + { + "successComment": + "This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:", + "labels": false, + "releasedLabels": false + } + ], + [ + "@semantic-release/changelog", + { + "changelogFile": "CHANGELOG.md", + "changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file." + } + ], + [ + "@semantic-release/git", + { + "assets": [ + "CHANGELOG.md" + ], + "message": "chore(release): version ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" + } + ] + ] +} diff --git a/.rspec b/.rspec deleted file mode 100644 index 16f9cdb..0000000 --- a/.rspec +++ /dev/null @@ -1,2 +0,0 @@ ---color ---format documentation diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 8e8299d..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.4.2 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fa2f0e9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -language: ruby -sudo: required -dist: trusty - -services: -- docker - -rvm: -- 2.4.2 - -before_install: -- echo "before_install" - -install: -- echo "install" -- gem install bundler --no-rdoc --no-ri -- bundle install - -before_script: -- echo 'before_script' -- export AWS_REGION='us-east-1' -- export TF_VAR_region=${AWS_REGION} -- echo "using AWS_REGION=${AWS_REGION}" -- export TF_WARN_OUTPUT_ERRORS=1 -- curl --silent --output terraform.zip https://releases.hashicorp.com/terraform/0.11.7/terraform_0.11.7_linux_amd64.zip -- sha256sum terraform.zip | grep "6b8ce67647a59b2a3f70199c304abca0ddec0e49fd060944c26f666298e23418" -- unzip terraform.zip ; rm -f terraform.zip; chmod +x terraform -- mkdir -p ${HOME}/bin ; export PATH=${PATH}:${HOME}/bin; mv terraform ${HOME}/bin/ -- terraform -v - -script: -- echo 'script' -- terraform init -- terraform fmt -check=true -- terraform validate -var "region=${AWS_REGION}" -var "instance_type=t2.micro" -- docker run --rm -v $(pwd):/app/ --workdir=/app/ -t wata727/tflint --error-with-issues -- cd examples/ebs_optimized_test_fixture -- terraform init -- terraform fmt -check=true -- terraform validate -- cd - -- terraform -v -- bundle exec kitchen test --destroy always - -notifications: - email: - recipients: - - brandon@atscale.run - on_success: change - on_failure: change diff --git a/CHANGELOG.md b/CHANGELOG.md index 34fca48..e69de29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +0,0 @@ -# Change Log - -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/). - -## [v0.1.0] - 2018-06-08 - -### Added - -- Everything! Initial release of the module. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 7730bca..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,46 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment include: - -- Using welcoming and inclusive language -- Being respectful of differing viewpoints and experiences -- Gracefully accepting constructive criticism -- Focusing on what is best for the community -- Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -- The use of sexualized language or imagery and unwelcome sexual attention or advances -- Trolling, insulting/derogatory comments, and personal or political attacks -- Public or private harassment -- Publishing others' private information, such as a physical or electronic address, without explicit permission -- Other conduct which could reasonably be considered inappropriate in a professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at brandon@atscale.run. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] - -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index b81ce2d..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,13 +0,0 @@ -# Contributing - -When contributing to this repository, please first discuss the change you wish to make via issue, -email, or any other method with the owners of this repository before making a change. - -Please note we have a code of conduct, please follow it in all your interactions with the project. - -## Pull Request Process - -1. Ensure any install or build dependencies are removed before the end of the layer when doing a build. -2. Update the README.md with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters. -3. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/). -4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you. diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 7ce51d2..0000000 --- a/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -ruby '2.4.2' - -source 'https://rubygems.org/' do - gem 'inspec', '~> 2.2.10' - gem 'kitchen-terraform', '~> 3.3.1' -# gem 'awspec', '~> 1.5.3' -end diff --git a/LICENSE b/LICENSE index 51fca54..d9a10c0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,11 +1,176 @@ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ - http://www.apache.org/licenses/LICENSE-2.0 + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/Makefile b/Makefile deleted file mode 100644 index 558dac5..0000000 --- a/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -.PHONY: changelog release - -changelog: - git-chglog -o CHANGELOG.md --next-tag `semtag final -s minor -o` - -release: - semtag final -s minor diff --git a/README.md b/README.md index 811651b..9a25bea 100644 --- a/README.md +++ b/README.md @@ -30,52 +30,6 @@ resource "aws_instance" "web" { } ``` -## Testing - -This module has been packaged with inspec tests through [kitchen](https://kitchen.ci/) and [kitchen-terraform](https://newcontext-oss.github.io/kitchen-terraform/). To run them: - -1. Install [rvm](https://rvm.io/rvm/install) and the ruby version specified in the [Gemfile](https://github.com/terraform-aws-modules/terraform-aws-ebs-optimized/tree/master/Gemfile). -2. Install bundler and the gems from our Gemfile: - - ```bash - gem install bundler && bundle install - ``` - -3. Test using `bundle exec kitchen test` from the root of the repo. - -inspec AWS resources are relatively new and not working on all platforms yet. If -you're working with the module and tests are being skipped, ensure you verify functionality -manually in the AWS console. - -## Doc generation - -Documentation should be modified within `main.tf` and generated using [terraform-docs](https://github.com/segmentio/terraform-docs). -Generate them like so: - -```bash -go get github.com/segmentio/terraform-docs -terraform-docs md ./ | cat -s | ghead -n -1 > README.md -``` - -## Contributing - -Report issues/questions/feature requests on in the [issues](https://github.com/terraform-aws-modules/terraform-aws-ebs-optimized/issues/new) section. - -Full contributing [guidelines are covered here](https://github.com/terraform-aws-modules/terraform-aws-ebs-optimized/blob/master/CONTRIBUTING.md). - -## Change log - -The [changelog](https://github.com/terraform-aws-modules/terraform-aws-ebs-optimized/tree/master/CHANGELOG.md) captures all important release notes. - -## Authors - -Created and maintained by [Brandon O'Connor](https://github.com/brandoconnor) - brandon@atscale.run. -Many thanks to [the contributors listed here](https://github.com/terraform-aws-modules/terraform-aws-ebs-optimized/graphs/contributors)! - -## License - -MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-ebs-optimized/tree/master/LICENSE) for full details. - ## Inputs | Name | Description | Type | Default | Required | @@ -87,3 +41,7 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a | Name | Description | |------|-------------| | answer | Returns 1 (true) or 0 (false) depending on if the instance type is able to be EBS optimized. | + +## License + +Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-key-pair/tree/master/LICENSE) for full details. diff --git a/examples/ebs_optimized_test_fixture/main.tf b/examples/ebs_optimized_test_fixture/main.tf index 244a114..c5f5b25 100644 --- a/examples/ebs_optimized_test_fixture/main.tf +++ b/examples/ebs_optimized_test_fixture/main.tf @@ -1,9 +1,9 @@ locals { - tags = "${map("Environment", "test", - "GithubRepo", "terraform-aws-ebs-optimized", - "GithubOrg", "terraform-aws-modules", - "Workspace", "${terraform.workspace}", - )}" + tags = { + "Environment" = "test" + "GithubRepo" = "terraform-aws-ebs-optimized" + "GithubOrg" = "terraform-aws-modules" + } } provider "aws" { @@ -28,40 +28,40 @@ data "aws_ami" "ubuntu" { resource "aws_launch_configuration" "ebs_optimized" { name_prefix = "test_ebs_optimized" - image_id = "${data.aws_ami.ubuntu.id}" - instance_type = "${var.supported_type}" - ebs_optimized = "${module.supported_ebs.answer}" + image_id = data.aws_ami.ubuntu.id + instance_type = var.supported_type + ebs_optimized = module.supported_ebs.answer } resource "aws_launch_configuration" "ebs_not_optimized" { name_prefix = "test_ebs_not_optimized" - image_id = "${data.aws_ami.ubuntu.id}" - instance_type = "${var.unsupported_type}" - ebs_optimized = "${module.unsupported_ebs.answer}" + image_id = data.aws_ami.ubuntu.id + instance_type = var.unsupported_type + ebs_optimized = module.unsupported_ebs.answer } resource "aws_instance" "ebs_optimized" { - ami = "${data.aws_ami.ubuntu.id}" - instance_type = "${var.supported_type}" - ebs_optimized = "${module.supported_ebs.answer}" - tags = "${merge(local.tags, map("Name", "test_ebs_optimized"))}" + ami = data.aws_ami.ubuntu.id + instance_type = var.supported_type + ebs_optimized = module.supported_ebs.answer + tags = merge(local.tags, { "Name" = "test_ebs_optimized" }) } resource "aws_instance" "ebs_not_optimized" { - ami = "${data.aws_ami.ubuntu.id}" - instance_type = "${var.unsupported_type}" - ebs_optimized = "${module.unsupported_ebs.answer}" - tags = "${merge(local.tags, map("Name", "test_not_ebs_optimized"))}" + ami = data.aws_ami.ubuntu.id + instance_type = var.unsupported_type + ebs_optimized = module.unsupported_ebs.answer + tags = merge(local.tags, { "Name" = "test_not_ebs_optimized" }) } module "supported_ebs" { source = "../.." - instance_type = "${var.supported_type}" + instance_type = var.supported_type } module "unsupported_ebs" { source = "../.." - instance_type = "${var.unsupported_type}" + instance_type = var.unsupported_type } module "unknown_type" { diff --git a/examples/ebs_optimized_test_fixture/outputs.tf b/examples/ebs_optimized_test_fixture/outputs.tf index 2be2b28..102972f 100644 --- a/examples/ebs_optimized_test_fixture/outputs.tf +++ b/examples/ebs_optimized_test_fixture/outputs.tf @@ -1,24 +1,24 @@ output "supported" { - description = "Answer for a known supported type." - value = "${module.supported_ebs.answer}" + description = "Answer for a known supported type" + value = module.supported_ebs.answer } output "unsupported" { - description = "Answer for a known unsupported type." - value = "${module.unsupported_ebs.answer}" + description = "Answer for a known unsupported type" + value = module.unsupported_ebs.answer } output "unknown" { - description = "Answer for an unknown type." - value = "${module.unknown_type.answer}" + description = "Answer for an unknown type" + value = module.unknown_type.answer } output "ebs_optimized_instance_id" { - description = "ebs optimized EC2 instance ID." - value = "${aws_instance.ebs_optimized.id}" + description = "ebs optimized EC2 instance ID" + value = aws_instance.ebs_optimized.id } output "not_ebs_optimized_instance_id" { - description = "ebs optimized EC2 instance ID." - value = "${aws_instance.ebs_not_optimized.id}" + description = "ebs optimized EC2 instance ID" + value = aws_instance.ebs_not_optimized.id } diff --git a/examples/ebs_optimized_test_fixture/variables.tf b/examples/ebs_optimized_test_fixture/variables.tf index 20bbb00..40f67a1 100644 --- a/examples/ebs_optimized_test_fixture/variables.tf +++ b/examples/ebs_optimized_test_fixture/variables.tf @@ -1,9 +1,11 @@ variable "supported_type" { - description = "a supported ebs optimized type." + description = "a supported ebs optimized type" + type = string default = "m1.large" } variable "unsupported_type" { - description = "an unsupported ebs optimized type." + description = "an unsupported ebs optimized type" + type = string default = "c1.medium" } diff --git a/examples/ebs_optimized_test_fixture/versions.tf b/examples/ebs_optimized_test_fixture/versions.tf new file mode 100644 index 0000000..fe1f6e8 --- /dev/null +++ b/examples/ebs_optimized_test_fixture/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 0.13.1" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.0" + } + } +} diff --git a/main.tf b/main.tf index 355ba48..e86f21c 100644 --- a/main.tf +++ b/main.tf @@ -1,252 +1,434 @@ -/** -# terraform-aws-ebs-optimized - -* A terraform module to return true or false based on if an instance type -* supports the EBS optmized flag. If you want to use various instance types and -* EBS optimization, this module does the heavy lifting of determining if that's -* possible. Without the module, EC2 instance creation would fail on unsupported -* types and -- even worse -- launch configurations will create normally but fail -* silently when instances attempt to launch. This module means you don't need to -* think about that problem. - -* ## Usage example - -* A full example leveraging other community modules is contained in the [examples/ebs_optimized_test_fixture](https://github.com/terraform-aws-modules/terraform-aws-ebs-optimized/tree/master/examples/ebs_optimized_fixture). Here's the gist of using it via the Terraform registry: - -* ```hcl -* variable "web_type" { -* description = "Size/type of the host." -* default = "m1.large" -* } -* -* module "ebs_optimized" { -* source = "terraform-aws-modules/ebs-optimized/aws" -* instance_type = "${var.web_type}" -* } -* -* resource "aws_instance" "web" { -* ami = "${data.aws_ami.ubuntu.id}" -* instance_type = "${var.web_type}" -* ebs_optimized = "${module.ebs_optimized.answer}" -* } -* ``` - -* ## Testing - -* This module has been packaged with inspec tests through [kitchen](https://kitchen.ci/) and [kitchen-terraform](https://newcontext-oss.github.io/kitchen-terraform/). To run them: - -* 1. Install [rvm](https://rvm.io/rvm/install) and the ruby version specified in the [Gemfile](https://github.com/terraform-aws-modules/terraform-aws-ebs-optimized/tree/master/Gemfile). -* 2. Install bundler and the gems from our Gemfile: -* -* ```bash -* gem install bundler && bundle install -* ``` -* -* 3. Test using `bundle exec kitchen test` from the root of the repo. - -* inspec AWS resources are relatively new and not working on all platforms yet. If -* you're working with the module and tests are being skipped, ensure you verify functionality -* manually in the AWS console. - -* ## Doc generation - -* Documentation should be modified within `main.tf` and generated using [terraform-docs](https://github.com/segmentio/terraform-docs). -* Generate them like so: - -* ```bash -* go get github.com/segmentio/terraform-docs -* terraform-docs md ./ | cat -s | ghead -n -1 > README.md -* ``` - -* ## Contributing - -* Report issues/questions/feature requests on in the [issues](https://github.com/terraform-aws-modules/terraform-aws-ebs-optimized/issues/new) section. - -* Full contributing [guidelines are covered here](https://github.com/terraform-aws-modules/terraform-aws-ebs-optimized/blob/master/CONTRIBUTING.md). - -* ## Change log - -* The [changelog](https://github.com/terraform-aws-modules/terraform-aws-ebs-optimized/tree/master/CHANGELOG.md) captures all important release notes. - -* ## Authors - -* Created and maintained by [Brandon O'Connor](https://github.com/brandoconnor) - brandon@atscale.run. -* Many thanks to [the contributors listed here](https://github.com/terraform-aws-modules/terraform-aws-ebs-optimized/graphs/contributors)! - -* ## License - -* MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-ebs-optimized/tree/master/LICENSE) for full details. -*/ - locals { ebs_optimized = { - "a1.xlarge" = true - "a1.2xlarge" = true - "a1.4xlarge" = true - "a1.large" = true - "a1.medium" = true - "c1.medium" = false - "c1.xlarge" = true - "c3.2xlarge" = true - "c3.4xlarge" = true - "c3.8xlarge" = false - "c3.large" = false - "c3.xlarge" = true - "c4.2xlarge" = true - "c4.4xlarge" = true - "c4.8xlarge" = true - "c4.large" = true - "c4.xlarge" = true - "c5.18xlarge" = true - "c5.2xlarge" = true - "c5.4xlarge" = true - "c5.9xlarge" = true - "c5.large" = true - "c5.xlarge" = true - "c5d.18xlarge" = true - "c5d.2xlarge" = true - "c5d.4xlarge" = true - "c5d.9xlarge" = true - "c5d.large" = true - "c5d.xlarge" = true - "c5n.18xlarge" = true - "c5n.2xlarge" = true - "c5n.4xlarge" = true - "c5n.9xlarge" = true - "c5n.large" = true - "c5n.xlarge" = true - "cc2.8xlarge" = false - "cr1.8xlarge" = false - "d2.2xlarge" = true - "d2.4xlarge" = true - "d2.8xlarge" = true - "d2.xlarge" = true - "f1.16xlarge" = true - "f1.2xlarge" = true - "g2.2xlarge" = true - "g2.8xlarge" = false - "g3.16xlarge" = true - "g3.4xlarge" = true - "g3.8xlarge" = true - "g3s.xlarge" = true - "h1.16xlarge" = true - "h1.2xlarge" = true - "h1.4xlarge" = true - "h1.8xlarge" = true - "hs1.8xlarge" = false - "i2.2xlarge" = true - "i2.4xlarge" = true - "i2.8xlarge" = false - "i2.xlarge" = true - "i3.16xlarge" = true - "i3.2xlarge" = true - "i3.4xlarge" = true - "i3.8xlarge" = true - "i3.large" = true - "i3.metal" = true - "i3.xlarge" = true - "m1.large" = true - "m1.medium" = false - "m1.small" = false - "m1.xlarge" = true - "m2.2large" = false - "m2.2xlarge" = true - "m2.4xlarge" = true - "m2.xlarge" = false - "m3.2xlarge" = true - "m3.large" = false - "m3.medium" = false - "m3.xlarge" = true - "m4.10xlarge" = true - "m4.16xlarge" = true - "m4.2xlarge" = true - "m4.4xlarge" = true - "m4.large" = true - "m4.xlarge" = true - "m5.12xlarge" = true - "m5.24xlarge" = true - "m5.2xlarge" = true - "m5.4xlarge" = true - "m5.large" = true - "m5.xlarge" = true - "m5a.12xlarge" = true - "m5a.24xlarge" = true - "m5a.2xlarge" = true - "m5a.4xlarge" = true - "m5a.large" = true - "m5a.xlarge" = true - "m5d.12xlarge" = true - "m5d.24xlarge" = true - "m5d.2xlarge" = true - "m5d.4xlarge" = true - "m5d.large" = true - "m5d.xlarge" = true - "p2.16xlarge" = true - "p2.8xlarge" = true - "p2.xlarge" = true - "p3.16xlarge" = true - "p3.2xlarge" = true - "p3.8xlarge" = true - "r3.2xlarge" = false - "r3.2xlarge" = true - "r3.4xlarge" = true - "r3.8xlarge" = false - "r3.large" = false - "r3.xlarge" = true - "r4.16xlarge" = true - "r4.2xlarge" = true - "r4.4xlarge" = true - "r4.8xlarge" = true - "r4.large" = true - "r4.xlarge" = true - "r5a.12xlarge" = true - "r5a.24xlarge" = true - "r5a.2xlarge" = true - "r5a.4xlarge" = true - "r5a.large" = true - "r5a.xlarge" = true - "r5d.12xlarge" = true - "r5d.24xlarge" = true - "r5d.2xlarge" = true - "r5d.4xlarge" = true - "r5d.large" = true - "r5d.xlarge" = true - "r5.12xlarge" = true - "r5.24xlarge" = true - "r5.2xlarge" = true - "r5.4xlarge" = true - "r5.large" = true - "r5.xlarge" = true - "t1.micro" = false - "t2.2xlarge" = false - "t2.large" = false - "t2.medium" = false - "t2.micro" = false - "t2.nano" = false - "t2.small" = false - "t2.xlarge" = false - "t3.2xlarge" = true - "t3.large" = true - "t3.medium" = true - "t3.micro" = true - "t3.nano" = true - "t3.small" = true - "t3.xlarge" = true - "u-6tbl.metal" = true - "u-9tbl.metal" = true - "x1.16xlarge" = true - "x1.32xlarge" = true - "x1e.16xlarge" = true - "x1e.2xlarge" = true - "x1e.32xlarge" = true - "x1e.4xlarge" = true - "x1e.8xlarge" = true - "x1e.xlarge" = true - "z1d.12xlarge" = true - "z1d.2xlarge" = true - "z1d.3xlarge" = true - "z1d.6xlarge" = true - "z1d.xlarge" = true - "z1d.large" = true + "a1.2xlarge" = true + "a1.4xlarge" = true + "a1.large" = true + "a1.medium" = true + "a1.metal" = true + "a1.xlarge" = true + "c1.medium" = false + "c1.xlarge" = true + "c3.2xlarge" = true + "c3.4xlarge" = true + "c3.8xlarge" = false + "c3.large" = false + "c3.xlarge" = true + "c4.2xlarge" = true + "c4.4xlarge" = true + "c4.8xlarge" = true + "c4.large" = true + "c4.xlarge" = true + "c5.12xlarge" = true + "c5.18xlarge" = true + "c5.24xlarge" = true + "c5.2xlarge" = true + "c5.4xlarge" = true + "c5.9xlarge" = true + "c5.large" = true + "c5.metal" = true + "c5.xlarge" = true + "c5a.12xlarge" = true + "c5a.16xlarge" = true + "c5a.24xlarge" = true + "c5a.2xlarge" = true + "c5a.4xlarge" = true + "c5a.8xlarge" = true + "c5a.large" = true + "c5a.xlarge" = true + "c5ad.12xlarge" = true + "c5ad.16xlarge" = true + "c5ad.24xlarge" = true + "c5ad.2xlarge" = true + "c5ad.4xlarge" = true + "c5ad.8xlarge" = true + "c5ad.large" = true + "c5ad.xlarge" = true + "c5d.12xlarge" = true + "c5d.18xlarge" = true + "c5d.24xlarge" = true + "c5d.2xlarge" = true + "c5d.4xlarge" = true + "c5d.9xlarge" = true + "c5d.large" = true + "c5d.metal" = true + "c5d.xlarge" = true + "c5n.18xlarge" = true + "c5n.2xlarge" = true + "c5n.4xlarge" = true + "c5n.9xlarge" = true + "c5n.large" = true + "c5n.metal" = true + "c5n.xlarge" = true + "c6g.12xlarge" = true + "c6g.16xlarge" = true + "c6g.2xlarge" = true + "c6g.4xlarge" = true + "c6g.8xlarge" = true + "c6g.large" = true + "c6g.medium" = true + "c6g.metal" = true + "c6g.xlarge" = true + "c6gd.12xlarge" = true + "c6gd.16xlarge" = true + "c6gd.2xlarge" = true + "c6gd.4xlarge" = true + "c6gd.8xlarge" = true + "c6gd.large" = true + "c6gd.medium" = true + "c6gd.metal" = true + "c6gd.xlarge" = true + "c6gn.12xlarge" = true + "c6gn.16xlarge" = true + "c6gn.2xlarge" = true + "c6gn.4xlarge" = true + "c6gn.8xlarge" = true + "c6gn.large" = true + "c6gn.medium" = true + "c6gn.xlarge" = true + "c6i.12xlarge" = true + "c6i.16xlarge" = true + "c6i.24xlarge" = true + "c6i.2xlarge" = true + "c6i.32xlarge" = true + "c6i.4xlarge" = true + "c6i.8xlarge" = true + "c6i.large" = true + "c6i.metal" = true + "c6i.xlarge" = true + "cc2.8xlarge" = false + "d2.2xlarge" = true + "d2.4xlarge" = true + "d2.8xlarge" = true + "d2.xlarge" = true + "d3.2xlarge" = true + "d3.4xlarge" = true + "d3.8xlarge" = true + "d3.xlarge" = true + "d3en.12xlarge" = true + "d3en.2xlarge" = true + "d3en.4xlarge" = true + "d3en.6xlarge" = true + "d3en.8xlarge" = true + "d3en.xlarge" = true + "dl1.24xlarge" = true + "f1.16xlarge" = true + "f1.2xlarge" = true + "f1.4xlarge" = true + "g2.2xlarge" = true + "g2.8xlarge" = false + "g3.16xlarge" = true + "g3.4xlarge" = true + "g3.8xlarge" = true + "g3s.xlarge" = true + "g4ad.16xlarge" = true + "g4ad.2xlarge" = true + "g4ad.4xlarge" = true + "g4ad.8xlarge" = true + "g4ad.xlarge" = true + "g4dn.12xlarge" = true + "g4dn.16xlarge" = true + "g4dn.2xlarge" = true + "g4dn.4xlarge" = true + "g4dn.8xlarge" = true + "g4dn.metal" = true + "g4dn.xlarge" = true + "g5.12xlarge" = true + "g5.16xlarge" = true + "g5.24xlarge" = true + "g5.2xlarge" = true + "g5.48xlarge" = true + "g5.4xlarge" = true + "g5.8xlarge" = true + "g5.xlarge" = true + "h1.16xlarge" = true + "h1.2xlarge" = true + "h1.4xlarge" = true + "h1.8xlarge" = true + "i2.2xlarge" = true + "i2.4xlarge" = true + "i2.8xlarge" = false + "i2.xlarge" = true + "i3.16xlarge" = true + "i3.2xlarge" = true + "i3.4xlarge" = true + "i3.8xlarge" = true + "i3.large" = true + "i3.metal" = true + "i3.xlarge" = true + "i3en.12xlarge" = true + "i3en.24xlarge" = true + "i3en.2xlarge" = true + "i3en.3xlarge" = true + "i3en.6xlarge" = true + "i3en.large" = true + "i3en.metal" = true + "i3en.xlarge" = true + "inf1.24xlarge" = true + "inf1.2xlarge" = true + "inf1.6xlarge" = true + "inf1.xlarge" = true + "m1.large" = true + "m1.medium" = false + "m1.small" = false + "m1.xlarge" = true + "m2.2xlarge" = true + "m2.4xlarge" = true + "m2.xlarge" = false + "m3.2xlarge" = true + "m3.large" = false + "m3.medium" = false + "m3.xlarge" = true + "m4.10xlarge" = true + "m4.16xlarge" = true + "m4.2xlarge" = true + "m4.4xlarge" = true + "m4.large" = true + "m4.xlarge" = true + "m5.12xlarge" = true + "m5.16xlarge" = true + "m5.24xlarge" = true + "m5.2xlarge" = true + "m5.4xlarge" = true + "m5.8xlarge" = true + "m5.large" = true + "m5.metal" = true + "m5.xlarge" = true + "m5a.12xlarge" = true + "m5a.16xlarge" = true + "m5a.24xlarge" = true + "m5a.2xlarge" = true + "m5a.4xlarge" = true + "m5a.8xlarge" = true + "m5a.large" = true + "m5a.xlarge" = true + "m5ad.12xlarge" = true + "m5ad.16xlarge" = true + "m5ad.24xlarge" = true + "m5ad.2xlarge" = true + "m5ad.4xlarge" = true + "m5ad.8xlarge" = true + "m5ad.large" = true + "m5ad.xlarge" = true + "m5d.12xlarge" = true + "m5d.16xlarge" = true + "m5d.24xlarge" = true + "m5d.2xlarge" = true + "m5d.4xlarge" = true + "m5d.8xlarge" = true + "m5d.large" = true + "m5d.metal" = true + "m5d.xlarge" = true + "m5dn.12xlarge" = true + "m5dn.16xlarge" = true + "m5dn.24xlarge" = true + "m5dn.2xlarge" = true + "m5dn.4xlarge" = true + "m5dn.8xlarge" = true + "m5dn.large" = true + "m5dn.metal" = true + "m5dn.xlarge" = true + "m5n.12xlarge" = true + "m5n.16xlarge" = true + "m5n.24xlarge" = true + "m5n.2xlarge" = true + "m5n.4xlarge" = true + "m5n.8xlarge" = true + "m5n.large" = true + "m5n.metal" = true + "m5n.xlarge" = true + "m5zn.12xlarge" = true + "m5zn.2xlarge" = true + "m5zn.3xlarge" = true + "m5zn.6xlarge" = true + "m5zn.large" = true + "m5zn.metal" = true + "m5zn.xlarge" = true + "m6g.12xlarge" = true + "m6g.16xlarge" = true + "m6g.2xlarge" = true + "m6g.4xlarge" = true + "m6g.8xlarge" = true + "m6g.large" = true + "m6g.medium" = true + "m6g.metal" = true + "m6g.xlarge" = true + "m6gd.12xlarge" = true + "m6gd.16xlarge" = true + "m6gd.2xlarge" = true + "m6gd.4xlarge" = true + "m6gd.8xlarge" = true + "m6gd.large" = true + "m6gd.medium" = true + "m6gd.metal" = true + "m6gd.xlarge" = true + "m6i.12xlarge" = true + "m6i.16xlarge" = true + "m6i.24xlarge" = true + "m6i.2xlarge" = true + "m6i.32xlarge" = true + "m6i.4xlarge" = true + "m6i.8xlarge" = true + "m6i.large" = true + "m6i.metal" = true + "m6i.xlarge" = true + "mac1.metal" = true + "p2.16xlarge" = true + "p2.8xlarge" = true + "p2.xlarge" = true + "p3.16xlarge" = true + "p3.2xlarge" = true + "p3.8xlarge" = true + "p3dn.24xlarge" = true + "p4d.24xlarge" = true + "r3.2xlarge" = true + "r3.4xlarge" = true + "r3.8xlarge" = false + "r3.large" = false + "r3.xlarge" = true + "r4.16xlarge" = true + "r4.2xlarge" = true + "r4.4xlarge" = true + "r4.8xlarge" = true + "r4.large" = true + "r4.xlarge" = true + "r5.12xlarge" = true + "r5.16xlarge" = true + "r5.24xlarge" = true + "r5.2xlarge" = true + "r5.4xlarge" = true + "r5.8xlarge" = true + "r5.large" = true + "r5.metal" = true + "r5.xlarge" = true + "r5a.12xlarge" = true + "r5a.16xlarge" = true + "r5a.24xlarge" = true + "r5a.2xlarge" = true + "r5a.4xlarge" = true + "r5a.8xlarge" = true + "r5a.large" = true + "r5a.xlarge" = true + "r5ad.12xlarge" = true + "r5ad.16xlarge" = true + "r5ad.24xlarge" = true + "r5ad.2xlarge" = true + "r5ad.4xlarge" = true + "r5ad.8xlarge" = true + "r5ad.large" = true + "r5ad.xlarge" = true + "r5b.12xlarge" = true + "r5b.16xlarge" = true + "r5b.24xlarge" = true + "r5b.2xlarge" = true + "r5b.4xlarge" = true + "r5b.8xlarge" = true + "r5b.large" = true + "r5b.metal" = true + "r5b.xlarge" = true + "r5d.12xlarge" = true + "r5d.16xlarge" = true + "r5d.24xlarge" = true + "r5d.2xlarge" = true + "r5d.4xlarge" = true + "r5d.8xlarge" = true + "r5d.large" = true + "r5d.metal" = true + "r5d.xlarge" = true + "r5dn.12xlarge" = true + "r5dn.16xlarge" = true + "r5dn.24xlarge" = true + "r5dn.2xlarge" = true + "r5dn.4xlarge" = true + "r5dn.8xlarge" = true + "r5dn.large" = true + "r5dn.metal" = true + "r5dn.xlarge" = true + "r5n.12xlarge" = true + "r5n.16xlarge" = true + "r5n.24xlarge" = true + "r5n.2xlarge" = true + "r5n.4xlarge" = true + "r5n.8xlarge" = true + "r5n.large" = true + "r5n.metal" = true + "r5n.xlarge" = true + "r6g.12xlarge" = true + "r6g.16xlarge" = true + "r6g.2xlarge" = true + "r6g.4xlarge" = true + "r6g.8xlarge" = true + "r6g.large" = true + "r6g.medium" = true + "r6g.metal" = true + "r6g.xlarge" = true + "r6gd.12xlarge" = true + "r6gd.16xlarge" = true + "r6gd.2xlarge" = true + "r6gd.4xlarge" = true + "r6gd.8xlarge" = true + "r6gd.large" = true + "r6gd.medium" = true + "r6gd.metal" = true + "r6gd.xlarge" = true + "t1.micro" = false + "t2.2xlarge" = false + "t2.large" = false + "t2.medium" = false + "t2.micro" = false + "t2.nano" = false + "t2.small" = false + "t2.xlarge" = false + "t3.2xlarge" = true + "t3.large" = true + "t3.medium" = true + "t3.micro" = true + "t3.nano" = true + "t3.small" = true + "t3.xlarge" = true + "t3a.2xlarge" = true + "t3a.large" = true + "t3a.medium" = true + "t3a.micro" = true + "t3a.nano" = true + "t3a.small" = true + "t3a.xlarge" = true + "t4g.2xlarge" = true + "t4g.large" = true + "t4g.medium" = true + "t4g.micro" = true + "t4g.nano" = true + "t4g.small" = true + "t4g.xlarge" = true + "u-12tb1.112xlarge" = true + "u-6tb1.112xlarge" = true + "u-6tb1.56xlarge" = true + "u-9tb1.112xlarge" = true + "vt1.24xlarge" = true + "vt1.3xlarge" = true + "vt1.6xlarge" = true + "x1.16xlarge" = true + "x1.32xlarge" = true + "x1e.16xlarge" = true + "x1e.2xlarge" = true + "x1e.32xlarge" = true + "x1e.4xlarge" = true + "x1e.8xlarge" = true + "x1e.xlarge" = true + "x2gd.12xlarge" = true + "x2gd.16xlarge" = true + "x2gd.2xlarge" = true + "x2gd.4xlarge" = true + "x2gd.8xlarge" = true + "x2gd.large" = true + "x2gd.medium" = true + "x2gd.metal" = true + "x2gd.xlarge" = true + "z1d.12xlarge" = true + "z1d.2xlarge" = true + "z1d.3xlarge" = true + "z1d.6xlarge" = true + "z1d.large" = true + "z1d.metal" = true + "z1d.xlarge" = true } } diff --git a/outputs.tf b/outputs.tf index 6b6c734..177c31c 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,4 +1,4 @@ output "answer" { - description = "Returns 1 (true) or 0 (false) depending on if the instance type is able to be EBS optimized." - value = "${lookup(local.ebs_optimized, var.instance_type, 0)}" + description = "Returns 1 (true) or 0 (false) depending on if the instance type is able to be EBS optimized" + value = lookup(local.ebs_optimized, var.instance_type, 0) } diff --git a/test/integration/default/controls/ebs_optimized_spec.rb b/test/integration/default/controls/ebs_optimized_spec.rb deleted file mode 100644 index 8e9b8f9..0000000 --- a/test/integration/default/controls/ebs_optimized_spec.rb +++ /dev/null @@ -1 +0,0 @@ -# frozen_string_literal: true diff --git a/test/integration/default/controls/inspec_attributes.rb b/test/integration/default/controls/inspec_attributes.rb deleted file mode 100644 index 5ba9d38..0000000 --- a/test/integration/default/controls/inspec_attributes.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -supported = - attribute( - "supported", - description: "" - ) - -unsupported_type_result = - attribute( - "unsupported", - description: "" -) - -unknown_type_result = - attribute( - "unknown", - description: "" -) - -ebs_optimized_instance_id = - attribute( - "ebs_optimized_instance_id", - description: "" - ) -puts ebs_optimized_instance_id - -not_ebs_optimized_instance_id = - attribute( - "not_ebs_optimized_instance_id", - description: "" - ) - -control 'ebs_optimized' do - describe aws_ec2_instance(not_ebs_optimized_instance_id) do - it { should exist } - # ebs_optimized is not an attribute we can test through inspec yet - end - - describe aws_ec2_instance(ebs_optimized_instance_id) do - it { should exist } - end -end diff --git a/test/integration/default/inspec.yml b/test/integration/default/inspec.yml deleted file mode 100644 index f39f222..0000000 --- a/test/integration/default/inspec.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -name: default diff --git a/update.py b/update.py new file mode 100644 index 0000000..007fd51 --- /dev/null +++ b/update.py @@ -0,0 +1,36 @@ +import boto3 +from typing import Dict + +EC2_CLIENT = boto3.client("ec2", region_name="us-east-1") + + +def get_instances(ebs_support: str) -> Dict[str, str]: + """Get instance types by their `ebs_support` type""" + results = {} + paginator = EC2_CLIENT.get_paginator("describe_instance_types") + resp_itr = paginator.paginate( + Filters=[{"Name": "ebs-info.ebs-optimized-support", "Values": [ebs_support]}], + ) + + _type = "false" if ebs_support == "unsupported" else "true" + for instances in resp_itr: + for inst in instances.get("InstanceTypes"): + results[inst["InstanceType"]] = _type + return results + + +def update_instances(): + """Update `main.tf` with instance types and their EBS support designation""" + results = {} + for ebs_support in {"supported", "default", "unsupported"}: + results.update(get_instances(ebs_support=ebs_support)) + + with open("main.tf", "w") as wfile: + wfile.writelines("locals {\n ebs_optimized = {\n") + for k, v in sorted(results.items()): + wfile.writelines(f' "{k}" = {v}\n') + wfile.writelines(" }\n}") + + +if __name__ == "__main__": + update_instances() diff --git a/variables.tf b/variables.tf index 8670422..b6ca604 100644 --- a/variables.tf +++ b/variables.tf @@ -1,3 +1,4 @@ variable "instance_type" { - description = "Instance type to evaluate if EBS optimized is an option." + description = "Instance type to evaluate if EBS optimized is an option" + type = string } diff --git a/version b/version deleted file mode 100644 index b82608c..0000000 --- a/version +++ /dev/null @@ -1 +0,0 @@ -v0.1.0 diff --git a/versions.tf b/versions.tf new file mode 100644 index 0000000..fe1f6e8 --- /dev/null +++ b/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 0.13.1" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.0" + } + } +}