A Terraform module to create Google Service Accounts on Google Cloud Services (GCP).
This module supports Terraform version 1 and is compatible with the Terraform Google Provider version 4. and 5._**
This module is part of our Infrastructure as Code (IaC) framework that enables our users and customers to easily deploy and manage reusable, secure, and production-grade cloud infrastructure.
- Module Features
- Getting Started
- Module Argument Reference
- Module Configuration
- Module Outputs
- External Documentation
- Module Versioning
- About Mineiros
- Reporting Issues
- Contributing
- Makefile Targets
- License
This module implements the following terraform resources
google_service_account
and supports additional features of the following modules:
Most basic usage just setting required arguments:
module "terraform-google-service-account" {
source = "github.com/mineiros-io/terraform-google-service-account?ref=v0.1.1"
account_id = "service-account-id"
display_name = "Service Account"
}
See variables.tf and examples/ for details and use-cases.
-
account_id
: (Requiredstring
)The account id that is used to generate the service account email address and a stable unique id. It is unique within a project, must be 6-30 characters long, and match the regular expression
[a-z]([-a-z0-9]*[a-z0-9])
to comply with RFC1035. Changing this forces a new service account to be created. -
display_name
: (Optionalstring
)The display name for the service account. Can be updated without creating a new resource.
-
description
: (Optionalstring
)A text description of the service account. Must be less than or equal to 256 UTF-8 bytes.
-
project
: (Optionalstring
)The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
-
projects_access
: (Optionallist(projects_access)
)DEPRECATED: please convert existing access to project level IAM. This will be removed in the next breaking release.
Default is
[]
. -
folders_access
: (Optionallist(folders_access)
)DEPRECATED: please convert existing access to folder level IAM. This will be removed in the next breaking release.
Default is
[]
. -
organization_access
: (Optionalobject(organization_access)
)DEPRECATED: please convert existing access to organization level IAM. This will be removed in the next breaking release.
Default is
[]
.
-
iam
: (Optionallist(iam)
)A list of IAM access.
Example:
iam = [{ role = "roles/iam.serviceAccountUser" members = ["user:[email protected]"] }]
Each
iam
object in the list accepts the following attributes:-
members
: (Optionalset(string)
)Identities that will be granted the privilege in role. Each entry can have one of the following values:
allUsers
: A special identifier that represents anyone who is on the internet; with or without a Google account.allAuthenticatedUsers
: A special identifier that represents anyone who is authenticated with a Google account or a service account.user:{emailid}
: An email address that represents a specific Google account. For example, [email protected] or [email protected].serviceAccount:{emailid}
: An email address that represents a service account. For example, [email protected].group:{emailid}
: An email address that represents a Google group. For example, [email protected].domain:{domain}
: A G Suite domain (primary, instead of alias) name that represents all the users of that domain. For example, google.com or example.com.principalSet:{All identities in a group|All identities with a specific attribute value|All identities in a pool}
: Grants a role to all the identities in a workload identity pool, or to specific external identities based on their attributes. For details please see https://cloud.google.com/iam/docs/workload-identity-federation.principal:{Single Identity}:
Grants a role to the specified identitiey in a workload identity pool. For details please see https://cloud.google.com/iam/docs/workload-identity-federation.computed:{identifier}
: An existing key fromvar.computed_members_map
.
Default is
[]
. -
role
: (Optionalstring
)The role that should be applied. Note that custom roles must be of the format
[projects|organizations]/{parent-name}/roles/{role-name}
. -
authoritative
: (Optionalbool
)Whether to exclusively set (authoritative mode) or add (non-authoritative/additive mode) members to the role.
Default is
true
.
-
-
policy_bindings
: (Optionallist(policy_binding)
)A list of IAM policy bindings.
Example:
policy_bindings = [{ role = "roles/iam.serviceAccountUser" members = ["user:[email protected]"] condition = { title = "expires_after_2021_12_31" description = "Expiring at midnight of 2021-12-31" expression = "request.time < timestamp(\"2022-01-01T00:00:00Z\")" } }]
Each
policy_binding
object in the list accepts the following attributes:-
role
: (Requiredstring
)The role that should be applied.
-
members
: (Optionalset(string)
)Identities that will be granted the privilege in
role
.Default is
var.members
. -
condition
: (Optionalobject(condition)
)An IAM Condition for a given binding.
Example:
condition = { expression = "request.time < timestamp(\"2022-01-01T00:00:00Z\")" title = "expires_after_2021_12_31" }
The
condition
object accepts the following attributes:-
expression
: (Requiredstring
)Textual representation of an expression in Common Expression Language syntax.
-
title
: (Requiredstring
)A title for the expression, i.e. a short string describing its purpose.
-
description
: (Optionalstring
)An optional description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
-
-
-
computed_members_map
: (Optionalmap(string)
)A map of members to replace in
members
of various IAM settings to handle terraform computed values.Default is
{}
.
-
module_enabled
: (Optionalbool
)Specifies whether resources in the module will be created.
Default is
true
. -
module_depends_on
: (Optionallist(dependency)
)A list of dependencies. Any object can be assigned to this list to define a hidden external dependency.
Example:
module_depends_on = [ google_network.network ]
The following attributes are exported in the outputs of the module:
-
iam
: (list(iam)
)The
iam
resource objects that define the access to the resources. -
service_account
: (object(service_account)
)All attributes of the created
google_service_account
resource. -
project_iam_member
: (object(project_iam_member)
)DEPRECATED: This will be removed in the next breaking release.
-
folder_iam_member
: (object(folder_iam_member)
)DEPRECATED: This will be removed in the next breaking release.
-
organization_iam_member
: (object(organization_iam_member)
)DEPRECATED: This will be removed in the next breaking release.
- https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_service_account
- https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_service_account_iam
This Module follows the principles of Semantic Versioning (SemVer).
Given a version number MAJOR.MINOR.PATCH
, we increment the:
MAJOR
version when we make incompatible changes,MINOR
version when we add functionality in a backwards compatible manner, andPATCH
version when we make backwards compatible bug fixes.
- Backwards compatibility in versions
0.0.z
is not guaranteed whenz
is increased. (Initial development) - Backwards compatibility in versions
0.y.z
is not guaranteed wheny
is increased. (Pre-release)
Mineiros is a remote-first company headquartered in Berlin, Germany that solves development, automation and security challenges in cloud infrastructure.
Our vision is to massively reduce time and overhead for teams to manage and deploy production-grade and secure cloud infrastructure.
We offer commercial support for all of our modules and encourage you to reach out if you have any questions or need help. Feel free to email us at [email protected] or join our Community Slack channel.
We use GitHub Issues to track community reported issues and missing features.
Contributions are always encouraged and welcome! For the process of accepting changes, we use Pull Requests. If you'd like more information, please see our Contribution Guidelines.
This repository comes with a handy Makefile.
Run make help
to see details on each available target.
This module is licensed under the Apache License Version 2.0, January 2004. Please see LICENSE for full details.
Copyright © 2020-2022 Mineiros GmbH