diff --git a/.github/workflows/readme.yml b/.github/workflows/readme.yml new file mode 100644 index 0000000..49e3ab6 --- /dev/null +++ b/.github/workflows/readme.yml @@ -0,0 +1,54 @@ +name: 'Create README.md file' +on: + push: + branches: + - master + +jobs: + readme-create: + name: 'readme-create' + runs-on: ubuntu-latest + steps: + - name: 'Checkout' + uses: actions/checkout@master + + - name: Set up Python 3.7. + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: 'create readme' + uses: 'clouddrove/github-actions@v4.0' + with: + actions_subcommand: 'readme' + github_token: '${{ secrets.GITHUB}}' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}} + + + - name: pre-commit check errors + uses: pre-commit/action@v2.0.0 + continue-on-error: true + + - name: pre-commit fix erros + uses: pre-commit/action@v2.0.0 + continue-on-error: true + + - name: 'push readme' + uses: 'clouddrove/github-actions@v4.0' + continue-on-error: true + with: + actions_subcommand: 'push' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}} + + - name: 'Slack Notification' + uses: clouddrove/action-slack@v2 + with: + status: ${{ job.status }} + fields: repo,author + author_name: 'CloudDrove' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required + if: always() diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 4a43daf..160e806 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -1,49 +1,54 @@ name: 'Terraform GitHub Actions' on: - - pull_request + pull_request: + branches: + - master jobs: terraform: name: 'Terraform' runs-on: ubuntu-latest steps: - - name: 'Checkout' uses: actions/checkout@master + - name: Configure AWS Credentials + uses: clouddrove/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }} + aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }} + aws-region: us-east-2 + - name: 'Terraform Format' - uses: clouddrove/github-actions@v2.0 + uses: 'clouddrove/github-actions@v4.0' with: actions_subcommand: 'fmt' - - name: 'Terraform Init' - uses: clouddrove/github-actions@v2.0 + - name: 'Terraform init' + uses: 'clouddrove/github-actions@v4.0' with: actions_subcommand: 'init' tf_actions_working_dir: ./_example - - name: Configure AWS Credentials - uses: clouddrove/configure-aws-credentials@v1 + - name: 'Terraform validate' + uses: 'clouddrove/github-actions@v4.0' with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-east-2 + actions_subcommand: 'validate' + tf_actions_working_dir: ./_example - - name: 'Terratest' - uses: clouddrove/github-actions@v2.0 + - name: 'Terraform plan' + uses: 'clouddrove/github-actions@v4.0' with: - actions_subcommand: 'terratest' - tf_actions_working_dir: ./_test - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + actions_subcommand: 'plan' + tf_actions_working_dir: ./_example - name: 'Slack Notification' uses: clouddrove/action-slack@v2 with: status: ${{ job.status }} fields: repo,author - author_name: 'Clouddrove' + author_name: 'CloudDrove' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} # required + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required if: always() \ No newline at end of file diff --git a/.github/workflows/terratest.yml b/.github/workflows/terratest.yml new file mode 100644 index 0000000..cb2d260 --- /dev/null +++ b/.github/workflows/terratest.yml @@ -0,0 +1,42 @@ +name: 'Terratest GitHub Actions' +on: + pull_request: + branches: + - master + types: [labeled] + +jobs: + terraform: + name: 'Terraform' + runs-on: ubuntu-latest + steps: + + - name: 'Checkout' + uses: actions/checkout@master + + - name: Configure AWS Credentials + uses: clouddrove/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }} + aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }} + aws-region: us-east-2 + + - name: 'Terratest' + if: ${{ github.event.label.name == 'terratest' }} + uses: 'clouddrove/github-actions@v4.0' + with: + actions_subcommand: 'terratest' + tf_actions_working_dir: '_test' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: 'Slack Notification' + uses: clouddrove/action-slack@v2 + with: + status: ${{ job.status }} + fields: repo,author + author_name: 'CloudDrove' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required + if: always() \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aa6e42c..9a789cb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,13 @@ repos: - repo: git://github.com/antonbabenko/pre-commit-terraform - rev: v1.12.0 + rev: v1.43.0 hooks: - id: terraform_fmt - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.0.0 + rev: v3.2.0 hooks: - id: check-merge-conflict - - id: trailing-whitespace - id: check-yaml - id: check-added-large-files + - id: trailing-whitespace \ No newline at end of file diff --git a/LICENSE b/LICENSE index 136d77d..807110a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Cloud Drove +Copyright (c) 2020 Cloud Drove Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.yaml b/README.yaml index 79ee8b5..fe13a42 100644 --- a/README.yaml +++ b/README.yaml @@ -5,7 +5,7 @@ # # Name of this project -name : Terraform AWS IAM Role +name: Terraform AWS IAM Role # License of this project license: "MIT" @@ -16,7 +16,7 @@ github_repo: clouddrove/terraform-aws-iam-role # Badges to display badges: - name: "Terraform" - image: "https://img.shields.io/badge/Terraform-v0.12-green" + image: "https://img.shields.io/badge/Terraform-v0.13-green" url: "https://www.terraform.io" - name: "Licence" image: "https://img.shields.io/badge/License-MIT-blue.svg" @@ -32,12 +32,14 @@ include: - "terraform.md" # How to use this project -usage : |- +# yamllint disable rule:line-length +usage: |- ### Simple example Here is an example of how you can use this module in your inventory structure: ```hcl module "iam-role" { - source = "git::https://github.com/clouddrove/terraform-aws-iam-role.git?ref=tags/0.12.3" + source = "clouddrove/iam-role/aws" + version = "0.13.0" name = "iam-role" application = "clouddrove" @@ -72,4 +74,4 @@ usage : |- resources = ["*"] } } - ``` \ No newline at end of file + ``` diff --git a/_test/go.mod b/_test/go.mod new file mode 100644 index 0000000..cc31f29 --- /dev/null +++ b/_test/go.mod @@ -0,0 +1,8 @@ +module github.com/clouddrove/terraform-aws-iam-role + +go 1.13 + +require ( + github.com/gruntwork-io/terratest v0.30.7 + github.com/stretchr/testify v1.6.1 +) diff --git a/main.tf b/main.tf index 05d99c5..6d8be9a 100644 --- a/main.tf +++ b/main.tf @@ -6,7 +6,7 @@ # for resources. You can use terraform-labels to implement a strict naming # convention. module "labels" { - source = "git::https://github.com/clouddrove/terraform-labels.git?ref=tags/0.12.0" + source = "git::https://github.com/clouddrove/terraform-labels.git?ref=tags/0.13.0" enabled = var.enabled name = var.name @@ -43,7 +43,7 @@ resource "aws_iam_role_policy" "default" { # Description : Terraform module to create IAm role policy resource on AWS to attach with Iam Role. resource "aws_iam_role_policy_attachment" "default" { count = var.enabled && var.policy_enabled && var.policy_arn != "" ? 1 : 0 - role = aws_iam_role.default.*.id[0] + role = aws_iam_role.default.*.id[0] policy_arn = var.policy_arn } diff --git a/versions.tf b/versions.tf index ea541ea..4597935 100644 --- a/versions.tf +++ b/versions.tf @@ -1,4 +1,9 @@ # Terraform version terraform { - required_version = ">= 0.12" + required_version = ">= 0.12.0, < 0.14.0" + required_providers { + aws = { + source = "hashicorp/aws" + } + } } \ No newline at end of file