Skip to content

Add unit tests #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 18, 2020
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
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/mineiros-io/pre-commit-hooks
rev: v0.1.1
rev: v0.1.4
hooks:
- id: terraform-fmt
- id: terraform-validate
Expand All @@ -9,3 +9,5 @@ repos:
- id: gofmt
- id: goimports
- id: golint
- id: phony-targets
- id: markdown-link-check
7 changes: 2 additions & 5 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ agent:
os_image: ubuntu1804

global_job_config:
# secrets:
# - name: TERRAFORM_AWS_TESTACCOUNT_CREDENTIALS
# - name: private-ssh-key-with-iac-library-access
secrets:
- name: TERRAFORM_AWS_TESTACCOUNT_CREDENTIALS
prologue:
commands:
- checkout --use-cache
# - chmod 400 ~/.ssh/id_rsa_iac_library
# - ssh-add ~/.ssh/id_rsa_iac_library

blocks:
- name: "Tests"
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* @soerenmartius @mariux
*.md @thenaturalist @soerenmartius @mariux
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Set default shell to bash
SHELL := /bin/bash -o pipefail

BUILD_TOOLS_VERSION ?= v0.4.0
BUILD_TOOLS_VERSION ?= v0.5.4
BUILD_TOOLS_DOCKER_REPO ?= mineiros/build-tools
BUILD_TOOLS_DOCKER_IMAGE ?= ${BUILD_TOOLS_DOCKER_REPO}:${BUILD_TOOLS_VERSION}

Expand Down Expand Up @@ -57,13 +57,16 @@ test/pre-commit:
test/unit-tests: DOCKER_FLAGS += ${DOCKER_SSH_FLAGS}
test/unit-tests: DOCKER_FLAGS += ${DOCKER_AWS_FLAGS}
test/unit-tests:
@echo "${YELLOW}No tests defined.${RESET}"
# $(call go-test,tests)
@echo "${YELLOW}[TEST] ${GREEN}Start Running Go Tests in Docker Container.${RESET}"
$(call go-test,./test/...)

## Clean up cache and temporary files
.PHONY: clean
clean:
$(call rm-command,.terraform)
$(call rm-command,*.tfplan)
$(call rm-command,examples/*/.terraform)
$(call rm-command,examples/*/*.tfplan)

## Display help for all targets
.PHONY: help
Expand All @@ -80,8 +83,6 @@ help:

# define helper functions
quiet-command = $(if ${V},${1},$(if ${2},@echo ${2} && ${1}, @${1}))

docker-run = $(call quiet-command,${DOCKER_RUN_CMD} ${1} | cat,"${YELLOW}[DOCKER RUN] ${GREEN}${1}${RESET}")
go-test = $(call quiet-command,${DOCKER_RUN_CMD} go test -v -timeout 45m -parallel 128 ${1} | cat,"${YELLOW}[TEST] ${GREEN}${1}${RESET}")

go-test = $(call quiet-command,${DOCKER_RUN_CMD} go test -v -count 1 -timeout 45m -parallel 128 ${1} | cat,"${YELLOW}[TEST] ${GREEN}${1}${RESET}")
rm-command = $(call quiet-command,rm -rf ${1},"${YELLOW}[CLEAN] ${GREEN}${1}${RESET}")
67 changes: 40 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[<img src="https://raw.githubusercontent.com/mineiros-io/brand/3bffd30e8bdbbde32c143e2650b2faa55f1df3ea/mineiros-primary-logo.svg" width="400"/>][homepage]

[![Build Status][badge-build]][build-status]
[![GitHub tag (latest SemVer)][badge-semver]][releases-github]
[![license][badge-license]][apache20]
[![Terraform Version][badge-terraform]][releases-terraform]
Expand Down Expand Up @@ -56,13 +57,14 @@ module "iam-users" {
names = [
"user.one",
"user.two",
"user.three"
"user.three",
]

policy_arns = [
"arn:aws:iam::aws:policy/ReadOnlyAccess",
"arn:aws:iam::aws:policy/job-function/Billing",
]
}
```

## Module Argument Reference
Expand Down Expand Up @@ -177,73 +179,84 @@ The following attributes are exported by the module:
- https://www.terraform.io/docs/providers/aws/r/iam_user_policy.html
- https://www.terraform.io/docs/providers/aws/r/iam_user_policy_attachment.html
- https://www.terraform.io/docs/providers/aws/r/iam_user_group_membership.html

## Module Versioning

This Module follows the principles of [Semantic Versioning (SemVer)](https://semver.org/).
This Module follows the principles of [Semantic Versioning (SemVer)].

Using the given version number of `MAJOR.MINOR.PATCH`, we apply the following constructs:
Given a version number `MAJOR.MINOR.PATCH`, we increment the:

1. Use the `MAJOR` version for incompatible changes.
1. Use the `MINOR` version when adding functionality in a backwards compatible manner.
1. Use the `PATCH` version when introducing backwards compatible bug fixes.
1. `MAJOR` version when we make incompatible changes,
2. `MINOR` version when we add functionality in a backwards compatible manner, and
3. `PATCH` version when we make backwards compatible bug fixes.

### Backwards compatibility in `0.0.z` and `0.y.z` version

- In the context of initial development, backwards compatibility in versions `0.0.z` is **not guaranteed** when `z` is
increased. (Initial development)
- In the context of pre-release, backwards compatibility in versions `0.y.z` is **not guaranteed** when `y` is
increased. (Pre-release)
- Backwards compatibility in versions `0.0.z` is **not guaranteed** when `z` is increased. (Initial development)
- Backwards compatibility in versions `0.y.z` is **not guaranteed** when `y` is increased. (Pre-release)

## About Mineiros

Mineiros is a [DevOps as a Service](https://mineiros.io/?ref=terraform-aws-iam-user) company based in Berlin, Germany. We offer commercial support
for all of our projects and encourage you to reach out if you have any questions or need help.
Feel free to send us an email at [hello@mineiros.io](mailto:hello@mineiros.io) or join our [Community Slack channel](https://join.slack.com/t/mineiros-community/shared_invite/zt-ehidestg-aLGoIENLVs6tvwJ11w9WGg).
Mineiros is a [DevOps as a Service][homepage] company based in Berlin, Germany.
We offer commercial support for all of our projects and encourage you to reach out
if you have any questions or need help. Feel free to send us an email at [hello@mineiros.io] or join our [Community Slack channel][slack].

We can also help you with:

- Terraform Modules for all types of infrastructure such as VPC's, Docker clusters,
databases, logging and monitoring, CI, etc.
- Consulting & Training on AWS, Terraform and DevOps.
- Terraform modules for all types of infrastructure such as VPCs, Docker clusters, databases, logging and monitoring, CI, etc.
- Consulting & training on AWS, Terraform and DevOps

## Reporting Issues

We use GitHub [Issues](https://github.com/mineiros-io/terraform-aws-iam-user/issues)
to track community reported issues and missing features.
We use GitHub [Issues] to track community reported issues and missing features.

## Contributing

Contributions are always encouraged and welcome! For the process of accepting changes, we use
[Pull Requests](https://github.com/mineiros-io/terraform-aws-iam-user/pulls). If you’d like more information, please
see our [Contribution Guidelines](https://github.com/mineiros-io/terraform-aws-iam-user/blob/master/CONTRIBUTING.md).
[Pull Requests]. If you'd like more information, please see our [Contribution Guidelines].

## Makefile Targets

This repository comes with a handy
[Makefile](https://github.com/mineiros-io/terraform-aws-iam-user/blob/master/Makefile).
This repository comes with a handy [Makefile].
Run `make help` to see details on each available target.

## License

This module is licensed under the Apache License Version 2.0, January 2004.
Please see [LICENSE](https://github.com/mineiros-io/terraform-aws-iam-user/blob/master/LICENSE) for full details.
Please see [LICENSE] for full details.

Copyright &copy; 2020 Mineiros
Copyright &copy; 2020 [Mineiros GmbH][homepage]

<!-- References -->

[homepage]: https://mineiros.io/?ref=terraform-aws-iam-user
[hello@mineiros.io]: mailto:hello@mineiros.io

[badge-build]: https://mineiros.semaphoreci.com/badges/terraform-aws-iam-user/branches/master.svg?style=shields&key=e7037b28-8872-4dff-8ce1-484d8a971e8a
[badge-semver]: https://img.shields.io/github/v/tag/mineiros-io/terraform-aws-iam-user.svg?label=latest&sort=semver
[badge-license]: https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg
[badge-terraform]: https://img.shields.io/badge/terraform-0.13%20and%200.12.20+-623CE4.svg?logo=terraform
[badge-slack]: https://img.shields.io/badge/slack-@mineiros--community-f32752.svg?logo=slack
[badge-semver]: https://img.shields.io/github/v/tag/mineiros-io/terraform-aws-iam-user.svg?label=latest&sort=semver

<!-- markdown-link-check-disable -->
[build-status]: https://mineiros.semaphoreci.com/projects/terraform-aws-iam-user
[releases-github]: https://github.com/mineiros-io/terraform-aws-iam-user/releases
<!-- markdown-link-check-enable -->
[releases-terraform]: https://github.com/hashicorp/terraform/releases
[apache20]: https://opensource.org/licenses/Apache-2.0
[slack]: https://join.slack.com/t/mineiros-community/shared_invite/zt-ehidestg-aLGoIENLVs6tvwJ11w9WGg

[Terraform]: https://www.terraform.io
[AWS]: https://aws.amazon.com/
[Semantic Versioning (SemVer)]: https://semver.org/

<!-- markdown-link-check-disable -->
[examples/example/main.tf]: https://github.com/mineiros-io/terraform-aws-iam-user/blob/master/examples/example/main.tf
[variables.tf]: https://github.com/mineiros-io/terraform-aws-iam-user/blob/master/variables.tf
[examples]: https://github.com/mineiros-io/terraform-aws-iam-user/blob/master/examples
[examples/]: https://github.com/mineiros-io/terraform-aws-iam-user/blob/master/examples
[Issues]: https://github.com/mineiros-io/terraform-aws-iam-user/issues
[LICENSE]: https://github.com/mineiros-io/terraform-aws-iam-user/blob/master/LICENSE
[Makefile]: https://github.com/mineiros-io/terraform-aws-iam-user/blob/master/Makefile
[Pull Requests]: https://github.com/mineiros-io/terraform-aws-iam-user/pulls
[Contribution Guidelines]: https://github.com/mineiros-io/terraform-aws-iam-user/blob/master/CONTRIBUTING.md
<!-- markdown-link-check-enable -->
8 changes: 5 additions & 3 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
- [simple-users/] Create IAM Users with two Policy ARNs attached.

<!-- References -->

[require-mfa-credentials/]: https://github.com/mineiros-io/terraform-aws-iam-user/blob/master/examples/require-mfa-credentials
[simple-users/]: https://github.com/mineiros-io/terraform-aws-iam-user/blob/master/examples/simple-users
<!-- markdown-link-check-disable -->
[example/]: https://github.com/mineiros-io/terraform-aws-iam-user/blob/master/examples/example
<!-- markdown-link-check-enable -->

[homepage]: https://mineiros.io/?ref=terraform-aws-iam-user

Expand All @@ -21,7 +21,9 @@
[badge-slack]: https://img.shields.io/badge/slack-@mineiros--community-f32752.svg?logo=slack
[badge-semver]: https://img.shields.io/github/v/tag/mineiros-io/terraform-aws-iam-user.svg?label=latest&sort=semver

<!-- markdown-link-check-disable -->
[releases-github]: https://github.com/mineiros-io/terraform-aws-iam-user/releases
<!-- markdown-link-check-enable -->
[releases-terraform]: https://github.com/hashicorp/terraform/releases
[apache20]: https://opensource.org/licenses/Apache-2.0
[slack]: https://join.slack.com/t/mineiros-community/shared_invite/zt-ehidestg-aLGoIENLVs6tvwJ11w9WGg
2 changes: 2 additions & 0 deletions examples/require-mfa-credentials/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,7 @@ Run `terraform destroy -refresh=false -auto-approve` to destroy all previously c
[apache20]: https://opensource.org/licenses/Apache-2.0
[slack]: https://join.slack.com/t/mineiros-community/shared_invite/zt-ehidestg-aLGoIENLVs6tvwJ11w9WGg

<!-- markdown-link-check-disable -->
[main.tf]: https://github.com/mineiros-io/terraform-aws-iam-user/blob/master/examples/require-mfa-credentials/main.tf
<!-- markdown-link-check-enable -->
[AWS documentation example]: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_aws_my-sec-creds-self-manage.html
2 changes: 2 additions & 0 deletions examples/simple-users/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,6 @@ Run `terraform destroy -refresh=false -auto-approve` to destroy all previously c
[apache20]: https://opensource.org/licenses/Apache-2.0
[slack]: https://join.slack.com/t/mineiros-community/shared_invite/zt-ehidestg-aLGoIENLVs6tvwJ11w9WGg

<!-- markdown-link-check-disable -->
[main.tf]: https://github.com/mineiros-io/terraform-aws-iam-user/blob/master/examples/simple-users/main.tf
<!-- markdown-link-check-enable -->
11 changes: 7 additions & 4 deletions examples/simple-users/main.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# ------------------------------------------------------------------------------
# Example Setup
# ------------------------------------------------------------------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# CREATE MULTIPLE IAM USERS AT ONCE
# This example shows how to create multiple users at once by passing a list
# of desired usernames to the module. We also attach some default IAM Policies
# to the created users.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

provider "aws" {
version = "~> 2.0"
region = "eu-west-1"
}

# ------------------------------------------------------------------------------
# Example Usage
# CREATE THE IAM USERS AND ATTACH DEFAULT IAM POLICIES
# ------------------------------------------------------------------------------

module "iam-users" {
Expand Down
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/mineiros-io/terraform-aws-iam-user

go 1.14

require (
github.com/gruntwork-io/terratest v0.28.5
github.com/stretchr/testify v1.4.0
)
Loading