Skip to content

Commit

Permalink
Merge pull request #2 from clouddrove/CD-90
Browse files Browse the repository at this point in the history
github action
  • Loading branch information
anmolnagpal committed Dec 29, 2019
2 parents 80ff601 + f357b04 commit f41c42b
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 17 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: 'Terraform GitHub Actions'
on:
- pull_request

jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
steps:

- name: 'Checkout'
uses: actions/checkout@master

- name: 'Terraform Format'
uses: clouddrove/github-actions@v2.0
with:
actions_subcommand: 'fmt'

- name: 'Terraform Init'
uses: clouddrove/github-actions@v2.0
with:
actions_subcommand: 'init'
tf_actions_working_dir: ./_example

- name: Configure AWS Credentials
uses: clouddrove/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2

- name: 'Terraform Plan'
uses: clouddrove/github-actions@v2.0
with:
actions_subcommand: 'plan'
tf_actions_working_dir: ./_example
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 'Terratest'
uses: clouddrove/github-actions@v2.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 }} # required
if: always()
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ This module has a few dependencies:
### Simple Example
Here is an example of how you can use this module in your inventory structure:
```hcl
module "ecr" {
source = "git::https://github.com/clouddrove/terraform-aws-ecr.git?ref=tags/0.12.0"
name = "ecr"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
}
module "ecr" {
source = "git::https://github.com/clouddrove/terraform-aws-ecr.git?ref=tags/0.12.1"
name = "ecr"
application = "clouddrove"
environment = "test"
label_order = ["environment", "application", "name"]
}
```


Expand Down
4 changes: 2 additions & 2 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ usage : |-
Here is an example of how you can use this module in your inventory structure:
```hcl
module "ecr" {
source = "git::https://github.com/clouddrove/terraform-aws-ecr.git?ref=tags/0.12.0"
source = "git::https://github.com/clouddrove/terraform-aws-ecr.git?ref=tags/0.12.1"
name = "ecr"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
label_order = ["environment", "application", "name"]
}
```
4 changes: 2 additions & 2 deletions _example/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ provider "aws" {
}

module "ecr" {
source = "git::https://github.com/clouddrove/terraform-aws-ecr.git?ref=tags/0.12.0"
source = "./../"
name = "ecr"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
label_order = ["environment", "application", "name"]
}
2 changes: 1 addition & 1 deletion _test/ecr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ func Test(t *testing.T) {
Tags := terraform.OutputMap(t, terraformOptions, "tags")

// Check that we get back the outputs that we expect
assert.Equal(t, "test-ecr-clouddrove", Tags["Name"])
assert.Equal(t, "test-clouddrove-ecr", Tags["Name"])
assert.Contains(t, Arn, "arn:aws:ecr")
}
10 changes: 5 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ data "aws_iam_policy_document" "empty" {

data "aws_iam_policy_document" "resource_readonly_access" {
statement {
sid = "ReadonlyAccess"
sid = "ReadonlyAccess"
effect = "Allow"

principals {
Expand All @@ -94,7 +94,7 @@ data "aws_iam_policy_document" "resource_readonly_access" {

data "aws_iam_policy_document" "resource_full_access" {
statement {
sid = "FullAccess"
sid = "FullAccess"
effect = "Allow"

principals {
Expand Down Expand Up @@ -122,15 +122,15 @@ data "aws_iam_policy_document" "resource_full_access" {


data "aws_iam_policy_document" "resource" {
source_json = local.principals_readonly_access_non_empty ? join("", data.aws_iam_policy_document.resource_readonly_access.*.json) : join("", data.aws_iam_policy_document.empty.*.json)
source_json = local.principals_readonly_access_non_empty ? join("", data.aws_iam_policy_document.resource_readonly_access.*.json) : join("", data.aws_iam_policy_document.empty.*.json)
override_json = local.principals_full_access_non_empty ? join("", data.aws_iam_policy_document.resource_full_access.*.json) : join("", data.aws_iam_policy_document.empty.*.json)
}

# Module : ECR REPOSITORY
# Description : Provides an Elastic Container Registry Repository Policy.
resource "aws_ecr_repository_policy" "default" {
count = local.ecr_need_policy && var.enabled_ecr ? 1 : 0
count = local.ecr_need_policy && var.enabled_ecr ? 1 : 0
repository = join("", aws_ecr_repository.default.*.name)
policy = join("", data.aws_iam_policy_document.resource.*.json)
policy = join("", data.aws_iam_policy_document.resource.*.json)
}

0 comments on commit f41c42b

Please sign in to comment.