-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic fixture and tests for the fabric-project submodule
- Loading branch information
Showing
17 changed files
with
203 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
* @morgante @aaron-lane @adrienthebo | ||
|
||
# CFT Fabric | ||
/modules/fabric-project/ @terraform-google-modules/cft-fabric | ||
/modules/fabric-project/ @terraform-google-modules/cft-fabric |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Simple Project | ||
|
||
This example illustrates how to create a simple project using the `fabric-project` submodule. | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|:----:|:-----:|:-----:| | ||
| activate\_apis | Service APIs to enable. | list(string) | `<list>` | no | | ||
| billing\_account | Billing account id. | string | n/a | yes | | ||
| name | Project name, joined with prefix. | string | `"fabric-project"` | no | | ||
| owners | Optional list of IAM-format members to set as project owners. | list(string) | `<list>` | no | | ||
| parent | Organization or folder id, in the `organizations/nnn` or `folders/nnn` format. | string | n/a | yes | | ||
| prefix | Prefix prepended to project name, uses random id by default. | string | `""` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| name | The name of the created project. | | ||
| project\_id | The project id of the created project. | | ||
| project\_number | The project number of the created project. | | ||
|
||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright 2018 Google LLC | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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. | ||
*/ | ||
|
||
provider "google" { | ||
version = "~> 2.18.1" | ||
} | ||
|
||
module "fabric-project" { | ||
source = "../../../examples/fabric_project" | ||
|
||
name = "fabric-project" | ||
parent = var.folder_id | ||
billing_account = var.billing_account | ||
activate_apis = [ | ||
"compute.googleapis.com", | ||
"container.googleapis.com", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright 2018 Google LLC | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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. | ||
*/ | ||
|
||
output "project_id" { | ||
description = "The project id of the created project." | ||
value = module.fabric-project.project_id | ||
} | ||
|
||
output "name" { | ||
description = "The name of the created project." | ||
value = module.fabric-project.name | ||
} | ||
|
||
output "project_number" { | ||
description = "The project number of the created project." | ||
value = module.fabric-project.project_number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright 2018 Google LLC | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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. | ||
*/ | ||
|
||
variable "folder_id" { | ||
} | ||
|
||
variable "billing_account" { | ||
} |
Empty file.
Empty file.
61 changes: 61 additions & 0 deletions
61
test/integration/fabric_project/controls/project_fabric.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright 2018 Google LLC | ||
# | ||
# 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 | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# 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. | ||
|
||
project_id = attribute('project_id') | ||
|
||
control 'fabric-project' do | ||
title 'Submodule Project Fabric' | ||
|
||
describe command("gcloud projects describe #{project_id} --format=json") do | ||
its('exit_status') { should be 0 } | ||
its('stderr') { should eq '' } | ||
|
||
let(:metadata) do | ||
if subject.exit_status == 0 | ||
JSON.parse(subject.stdout, symbolize_names: true) | ||
else | ||
{} | ||
end | ||
end | ||
|
||
it { expect(metadata).to include(name: project_id[0...-5]) } | ||
it { expect(metadata).to include(projectId: project_id) } | ||
end | ||
|
||
describe command("gcloud services list --project #{project_id}") do | ||
its('exit_status') { should be 0 } | ||
its('stderr') { should eq '' } | ||
|
||
its('stdout') { should match(/compute\.googleapis\.com/) } | ||
its('stdout') { should match(/container\.googleapis\.com/) } | ||
end | ||
|
||
describe command("gcloud alpha resource-manager liens list --project #{project_id} --format=json") do | ||
its('exit_status') { should be 0 } | ||
its('stderr') { should eq '' } | ||
|
||
let(:liens) do | ||
if subject.exit_status == 0 | ||
JSON.parse(subject.stdout, symbolize_names: true) | ||
else | ||
[] | ||
end | ||
end | ||
|
||
it "has no liens" do | ||
expect(liens).to be_empty | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: fabric_project | ||
attributes: | ||
- name: project_id | ||
required: true | ||
|
||
- name: project_number | ||
required: true | ||
|
||
- name: name | ||
required: true |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters