- Terraform Website: https://terraform.io
- Terraform Registry: https://registry.terraform.io/providers/yamamoto-febc/gmailfilter/latest/
- Documentation: https://registry.terraform.io/providers/yamamoto-febc/gmailfilter/latest/docs
# Configure the gmailfilter Provider
terraform {
required_providers {
gmailfilter = {
source = "yamamoto-febc/gmailfilter"
# We recommend pinning to the specific version of the gmailfilter Provider you're using
# since new versions are released frequently
version = "1.1.0"
#version = "~> 1"
}
}
}
resource gmailfilter_filter "example" {
criteria {
# exclude_chats = false
from = "[email protected]"
# has_attachment = false
# negated_query = "from:[email protected] rfc822msgid: is:unread"
# query = "from:[email protected] rfc822msgid: is:unread"
# size = 1000
# size_comparison = "larger"
# subject = "example"
# to = "example@"
}
action {
add_label_ids = [gmailfilter_label.example.id]
remove_label_ids = [data.gmailfilter_label.INBOX.id]
}
}
data gmailfilter_label "INBOX" {
name = "INBOX"
}
resource gmailfilter_label "example" {
name = "example"
}- Terraform v0.12+
Follow the instruction at Enable and disable APIs to enable to the Gmail APIs.
There are two authentication methods available with this provider.
- Using a service account(G suite users only)
- Using an Application Default Credentials
Follow the instruction at https://developers.google.com/identity/protocols/oauth2/service-account#creatinganaccount.
Then, add credentials and impersonated_user_email to your tf file.
provider gmailfilter {
credentials = file("account.json")
impersonated_user_email = "[email protected]"
}You can also use these environment variables:
GOOGLE_APPLICATION_CREDENTIALSGOOGLE_CREDENTIALSGOOGLE_CLOUD_KEYFILE_JSONGCLOUD_KEYFILE_JSONIMPERSONATED_USER_EMAIL
First, you need to create credentials for the project.
https://console.cloud.google.com/apis/credentials?project=[project_ID]
Then, create an OAuth 2.0 client, and download the client secret file(JSON) to your local machine.
Finally, run the following command to use that credential to authenticate.
gcloud auth application-default login \
--client-id-file=client_secret.json \
--scopes \
https://www.googleapis.com/auth/gmail.labels,\
https://www.googleapis.com/auth/gmail.settings.basicTerraformer includes support for this provider and can generate Terraform files from your existing infrastructure.
See the Terraformer README for more information.
Currently, the provider doesn't support managing the forwarding addresses.
If you want to use forwarding in the gmailfilter_filter resource, please configure the forwarding addresses manually before using it.
For details, see Automatically forward Gmail messages to another account.
terraform-proivder-gmailfilter Copyright (C) 2020-2021 terraform-provider-gmailfilter authors.
This project is published under Mozilla Public License 2.0.