File tree Expand file tree Collapse file tree 10 files changed +33
-32
lines changed
examples/single_service_account
fixtures/single_service_account
integration/single_service_account Expand file tree Collapse file tree 10 files changed +33
-32
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ provider "google" {
2121module "service_accounts" {
2222 source = " ../.."
2323 project_id = " ${ var . project_id } "
24- prefix = " single-test "
25- names = [" first " ]
24+ prefix = " ${ var . prefix } "
25+ names = [" single-account " ]
2626 project_roles = [" ${ var . project_id } =>roles/viewer" ]
2727}
Original file line number Diff line number Diff line change @@ -18,3 +18,8 @@ variable "project_id" {
1818 description = " The ID of the project in which to provision resources."
1919 type = " string"
2020}
21+
22+ variable "prefix" {
23+ description = " Prefix applied to service account names."
24+ default = " "
25+ }
Original file line number Diff line number Diff line change @@ -26,18 +26,13 @@ platforms:
2626 - name : default
2727
2828suites :
29- - name : simple_example
29+ - name : single_service_account
3030 driver :
31- root_module_directory : test/fixtures/simple_example /
31+ root_module_directory : test/fixtures/single_service_account /
3232 verifier :
3333 color : false
3434 systems :
35- - name : simple_example local
36- backend : local
37- controls :
38- - gcloud
39- - gsutil
40- - name : simple_example gcp
35+ - name : single_service_account gcp
4136 backend : gcp
4237 controls :
4338 - gcp
Original file line number Diff line number Diff line change 1414 * limitations under the License.
1515 */
1616
17- provider "random" {
18- version = " ~> 2.0"
19- }
20-
21- resource "random_pet" "main" {
22- length = 1
23- prefix = " simple-example"
24- separator = " -"
25- }
26-
2717module "example" {
28- source = " ../../../examples/simple_example"
29-
30- project_id = " ${ var . project_id } "
31- bucket_name = " ${ random_pet . main . id } "
18+ source = " ../../../examples/single_service_account"
19+ project_id = " ${ var . project_id } "
3220}
Original file line number Diff line number Diff line change 1414 * limitations under the License.
1515 */
1616
17- output "bucket_name" {
18- description = " The name of the bucket."
19- value = " ${ module . example . bucket_name } "
17+ output "email" {
18+ description = " The service account email."
19+ value = " ${ module . example . email } "
20+ }
21+
22+ output "iam_email" {
23+ description = " The service account IAM-format email."
24+ value = " ${ module . example . iam_email } "
2025}
2126
2227output "project_id" {
23- description = " The ID of the project in which resources are provisioned ."
28+ description = " Project id variable ."
2429 value = " ${ var . project_id } "
2530}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1515control "gcp" do
1616 title "GCP Resources"
1717
18- describe google_storage_bucket ( name : attribute ( "bucket_name" ) ) do
19- it { should exist }
18+ describe google_service_account ( name : "projects/ #{ attribute ( "project_id" ) } /serviceAccounts/ #{ attribute ( "email" ) } " ) do
19+ its ( 'project_id' ) { should eq attribute ( 'project_id' ) }
2020 end
21+
22+ describe google_project_iam_binding ( project : "#{ attribute ( "project_id" ) } " , role : 'roles/viewer' ) do
23+ its ( 'members' ) { should include attribute ( 'iam_email' ) }
24+ end
25+
2126end
File renamed without changes.
Original file line number Diff line number Diff line change 1- name : simple_example
1+ name : single_service_account
22depends :
33 - name : inspec-gcp
44 git : https://github.com/inspec/inspec-gcp.git
@@ -7,6 +7,9 @@ attributes:
77 - name : project_id
88 required : true
99 type : string
10- - name : bucket_name
10+ - name : email
11+ required : true
12+ type : string
13+ - name : iam_email
1114 required : true
1215 type : string
You can’t perform that action at this time.
0 commit comments