Skip to content

Commit

Permalink
feat!: add Terraform 0.13 constraint and module attribution (#86)
Browse files Browse the repository at this point in the history
* feat!: add Terraform 0.13 constraint and module attribution

* bump example providers

* update inspec tests

Co-authored-by: bharathkkb <[email protected]>
  • Loading branch information
cloud-foundation-bot and bharathkkb authored Mar 25, 2021
1 parent 92f615f commit 2b94062
Show file tree
Hide file tree
Showing 51 changed files with 195 additions and 162 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Make will use bash instead of sh
SHELL := /usr/bin/env bash

DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.12.1
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.13
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
REGISTRY_URL := gcr.io/cloud-foundation-cicd

Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ are:
- A **Destination** (Cloud Storage bucket, Cloud Pub/Sub topic, BigQuery dataset)

## Compatibility

This module is meant for use with Terraform 0.12. If you haven't [upgraded](https://www.terraform.io/upgrade-guides/0-12.html) and need a Terraform 0.11.x-compatible version of this module, the last released version intended for Terraform 0.11.x is [2.3.0](https://registry.terraform.io/modules/terraform-google-modules/log-export/google/2.3.0).
This module is meant for use with Terraform 0.13. If you haven't
[upgraded](https://www.terraform.io/upgrade-guides/0-13.html) and need a Terraform
0.12.x-compatible version of this module, the last released version
intended for Terraform 0.12.x is [v5.1.0](https://registry.terraform.io/modules/terraform-google-modules/-log-export/google/v5.1.0).

## Usage

Expand Down Expand Up @@ -70,7 +72,7 @@ so that all dependencies are met.

## Requirements
### Terraform plugins
- [Terraform](https://www.terraform.io/downloads.html) 0.12.x
- [Terraform](https://www.terraform.io/downloads.html) >= 0.13.0
- [terraform-provider-google](https://github.com/terraform-providers/terraform-provider-google) plugin ~> v3.5.x

### Configure a Service Account
Expand Down
2 changes: 1 addition & 1 deletion build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ tags:
- 'integration'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.12.0'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13'
2 changes: 1 addition & 1 deletion build/lint.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ tags:
- 'lint'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.12.1'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13'
2 changes: 1 addition & 1 deletion examples/bigquery/billing_account/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ terraform {
}

provider "google" {
version = "~> 3.41.0"
version = "~> 3.53.0"
}
2 changes: 1 addition & 1 deletion examples/bigquery/folder/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ terraform {
}

provider "google" {
version = "~> 3.41.0"
version = "~> 3.53.0"
}
2 changes: 1 addition & 1 deletion examples/bigquery/organization/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ terraform {
}

provider "google" {
version = "~> 3.41.0"
version = "~> 3.53.0"
}
2 changes: 1 addition & 1 deletion examples/bigquery/project/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ terraform {
}

provider "google" {
version = "~> 3.41.0"
version = "~> 3.53.0"
}
2 changes: 1 addition & 1 deletion examples/datadog-sink/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

provider "google" {
version = "~> 3.41.0"
version = "~> 3.53.0"
}

locals {
Expand Down
2 changes: 1 addition & 1 deletion examples/pubsub/billing_account/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ terraform {
}

provider "google" {
version = "~> 3.41.0"
version = "~> 3.53.0"
}
2 changes: 1 addition & 1 deletion examples/pubsub/folder/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ terraform {
}

provider "google" {
version = "~> 3.41.0"
version = "~> 3.53.0"
}
2 changes: 1 addition & 1 deletion examples/pubsub/organization/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ terraform {
}

provider "google" {
version = "~> 3.41.0"
version = "~> 3.53.0"
}
2 changes: 1 addition & 1 deletion examples/pubsub/project/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ terraform {
}

provider "google" {
version = "~> 3.41.0"
version = "~> 3.53.0"
}
2 changes: 1 addition & 1 deletion examples/splunk-sink/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ terraform {
}

provider "google" {
version = "~> 3.41.0"
version = "~> 3.53.0"
}
2 changes: 1 addition & 1 deletion examples/storage/billing_account/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ terraform {
}

provider "google" {
version = "~> 3.41.0"
version = "~> 3.53.0"
}
2 changes: 1 addition & 1 deletion examples/storage/folder/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ terraform {
}

provider "google" {
version = "~> 3.41.0"
version = "~> 3.53.0"
}
2 changes: 1 addition & 1 deletion examples/storage/organization/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ terraform {
}

provider "google" {
version = "~> 3.41.0"
version = "~> 3.53.0"
}
2 changes: 1 addition & 1 deletion examples/storage/project/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ terraform {
}

provider "google" {
version = "~> 3.41.0"
version = "~> 3.53.0"
}
16 changes: 12 additions & 4 deletions modules/bigquery/versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2019 Google LLC
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,10 +14,18 @@
* limitations under the License.
*/


terraform {
required_version = ">=0.12.6"
required_version = ">= 0.13"
required_providers {
google = "~> 3.5"

google = {
source = "hashicorp/google"
version = "~> 3.53"
}
}

provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-log-export:bigquery/v1.0.0"
}

}
16 changes: 12 additions & 4 deletions modules/pubsub/versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2019 Google LLC
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,10 +14,18 @@
* limitations under the License.
*/


terraform {
required_version = ">=0.12.6"
required_version = ">= 0.13"
required_providers {
google = "~> 3.5"

google = {
source = "hashicorp/google"
version = "~> 3.53"
}
}

provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-log-export:pubsub/v1.0.0"
}

}
16 changes: 12 additions & 4 deletions modules/storage/versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2019 Google LLC
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,10 +14,18 @@
* limitations under the License.
*/


terraform {
required_version = ">=0.12.6"
required_version = ">= 0.13"
required_providers {
google = "~> 3.38"

google = {
source = "hashicorp/google"
version = "~> 3.53"
}
}

provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-log-export:storage/v1.0.0"
}

}
16 changes: 8 additions & 8 deletions test/integration/bigquery/folder/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
control "gcloud" do
title "Log exports - folder level bigquery destination - gcloud commands"

describe command("gcloud logging sinks list --folder #{log_export_map['parent_resource_id']} --filter=\"name:#{log_export_map['log_sink_resource_name']}\" --format json") do
describe command("gcloud logging sinks list --folder #{log_export_map[:parent_resource_id]} --filter=\"name:#{log_export_map[:log_sink_resource_name]}\" --format json") do
its('exit_status') { should eq 0 }
its('stderr') { should eq '' }
let(:sink) do
Expand All @@ -31,25 +31,25 @@

it "does return the correct log sink" do
expect(sink).to include(
name: log_export_map["log_sink_resource_name"]
name: log_export_map[:log_sink_resource_name]
)
end

it "does contain the writerIdentity of #{log_export_map['writer_identity']}" do
it "does contain the writerIdentity of #{log_export_map[:writer_identity]}" do
expect(sink).to include(
writerIdentity: log_export_map["writer_identity"]
writerIdentity: log_export_map[:writer_identity]
)
end

it "does contain the destination of #{destination_map['destination_uri']}" do
it "does contain the destination of #{destination_map[:destination_uri]}" do
expect(sink).to include(
destination: destination_map["destination_uri"]
destination: destination_map[:destination_uri]
)
end

it "does contain the filter of #{log_export_map['filter']}" do
it "does contain the filter of #{log_export_map[:filter]}" do
expect(sink).to include(
filter: log_export_map["filter"]
filter: log_export_map[:filter]
)
end
end
Expand Down
8 changes: 4 additions & 4 deletions test/integration/bigquery/folder/controls/gcp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
title "Log exports - folder level bigquery destination - native resources"

describe google_bigquery_dataset(
project: destination_map["project"],
name: destination_map["resource_name"],
project: destination_map[:project],
name: destination_map[:resource_name],
) do
it { should exist }
end

describe google_project_iam_binding(
project: destination_map["project"],
project: destination_map[:project],
role: 'roles/bigquery.dataEditor',
) do
it { should exist }
its('members') { should include log_export_map["writer_identity"] }
its('members') { should include log_export_map[:writer_identity] }
end
end
2 changes: 1 addition & 1 deletion test/integration/bigquery/folder/inspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: bigquery_folder
depends:
- name: inspec-gcp
git: https://github.com/inspec/inspec-gcp.git
tag: v0.10.0
tag: v1.8.0
attributes:
- name: log_export_map
required: true
Expand Down
16 changes: 8 additions & 8 deletions test/integration/bigquery/organization/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
control "gcloud" do
title "Log exports - organization level bigquery destination - gcloud commands"

describe command("gcloud logging sinks list --organization #{log_export_map['parent_resource_id']} --filter=\"name:#{log_export_map['log_sink_resource_name']}\" --format json") do
describe command("gcloud logging sinks list --organization #{log_export_map[:parent_resource_id]} --filter=\"name:#{log_export_map[:log_sink_resource_name]}\" --format json") do
its('exit_status') { should eq 0 }
its('stderr') { should eq '' }
let(:sink) do
Expand All @@ -31,25 +31,25 @@

it "does return the correct log sink" do
expect(sink).to include(
name: log_export_map["log_sink_resource_name"]
name: log_export_map[:log_sink_resource_name]
)
end

it "does contain the writerIdentity of #{log_export_map['writer_identity']}" do
it "does contain the writerIdentity of #{log_export_map[:writer_identity]}" do
expect(sink).to include(
writerIdentity: log_export_map["writer_identity"]
writerIdentity: log_export_map[:writer_identity]
)
end

it "does contain the destination of #{destination_map['destination_uri']}" do
it "does contain the destination of #{destination_map[:destination_uri]}" do
expect(sink).to include(
destination: destination_map["destination_uri"]
destination: destination_map[:destination_uri]
)
end

it "does contain the filter of #{log_export_map['filter']}" do
it "does contain the filter of #{log_export_map[:filter]}" do
expect(sink).to include(
filter: log_export_map["filter"]
filter: log_export_map[:filter]
)
end
end
Expand Down
8 changes: 4 additions & 4 deletions test/integration/bigquery/organization/controls/gcp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
title "Log exports - organization level bigquery destination - native resources"

describe google_bigquery_dataset(
project: destination_map["project"],
name: destination_map["resource_name"],
project: destination_map[:project],
name: destination_map[:resource_name],
) do
it { should exist }
end

describe google_project_iam_binding(
project: destination_map["project"],
project: destination_map[:project],
role: 'roles/bigquery.dataEditor',
) do
it { should exist }
its('members') { should include log_export_map["writer_identity"] }
its('members') { should include log_export_map[:writer_identity] }
end
end
2 changes: 1 addition & 1 deletion test/integration/bigquery/organization/inspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: bigquery_organization
depends:
- name: inspec-gcp
git: https://github.com/inspec/inspec-gcp.git
tag: v0.10.0
tag: v1.8.0
attributes:
- name: log_export_map
required: true
Expand Down
Loading

0 comments on commit 2b94062

Please sign in to comment.