Skip to content

Commit 3949264

Browse files
pay20glasnt
andauthored
feat(application integration): Add example for creating auth configs (#658)
* feat(application integration): Add example for creating auth configs * lint: correct region tag, whitespace * remove project_id declaration * lint: whitespace * add service account permission * ensure data included * dependency chaining * assign permissions to project service account * give both api and sa role, ensure dependence * terraform fmt * remove unstable samples (for now) --------- Co-authored-by: Katie McLaughlin <[email protected]>
1 parent ec992bc commit 3949264

File tree

2 files changed

+167
-1
lines changed
  • application_integration

2 files changed

+167
-1
lines changed
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
provider "google" {}
18+
19+
# [START application_integration_create_auth_config_auth_token]
20+
resource "google_integrations_client" "client" {
21+
location = "us-central1"
22+
}
23+
24+
resource "google_integrations_auth_config" "auth_config_auth_token" {
25+
location = "us-central1"
26+
display_name = "tf-auth-token"
27+
description = "Test auth config created via terraform"
28+
decrypted_credential {
29+
credential_type = "AUTH_TOKEN"
30+
auth_token {
31+
type = "Basic"
32+
token = "some-random-token"
33+
}
34+
}
35+
depends_on = [google_integrations_client.client]
36+
}
37+
# [END application_integration_create_auth_config_auth_token]
38+
39+
# [START application_integration_create_auth_config_certificate]
40+
resource "google_integrations_auth_config" "auth_config_certificate" {
41+
location = "us-central1"
42+
display_name = "tf-certificate"
43+
description = "Test auth config created via terraform"
44+
decrypted_credential {
45+
credential_type = "CLIENT_CERTIFICATE_ONLY"
46+
}
47+
client_certificate {
48+
ssl_certificate = <<EOT
49+
-----BEGIN CERTIFICATE-----
50+
MIICTTCCAbagAwIBAgIJAPT0tSKNxan/MA0GCSqGSIb3DQEBCwUAMCoxFzAVBgNV
51+
BAoTDkdvb2dsZSBURVNUSU5HMQ8wDQYDVQQDEwZ0ZXN0Q0EwHhcNMTUwMTAxMDAw
52+
MDAwWhcNMjUwMTAxMDAwMDAwWjAuMRcwFQYDVQQKEw5Hb29nbGUgVEVTVElORzET
53+
MBEGA1UEAwwKam9lQGJhbmFuYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA
54+
vDYFgMgxi5W488d9J7UpCInl0NXmZQpJDEHE4hvkaRlH7pnC71H0DLt0/3zATRP1
55+
JzY2+eqBmbGl4/sgZKYv8UrLnNyQNUTsNx1iZAfPUflf5FwgVsai8BM0pUciq1NB
56+
xD429VFcrGZNucvFLh72RuRFIKH8WUpiK/iZNFkWhZ0CAwEAAaN3MHUwDgYDVR0P
57+
AQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMB
58+
Af8EAjAAMBkGA1UdDgQSBBCVgnFBCWgL/iwCqnGrhTPQMBsGA1UdIwQUMBKAEKey
59+
Um2o4k2WiEVA0ldQvNYwDQYJKoZIhvcNAQELBQADgYEAYK986R4E3L1v+Q6esBtW
60+
JrUwA9UmJRSQr0N5w3o9XzarU37/bkjOP0Fw0k/A6Vv1n3vlciYfBFaBIam1qRHr
61+
5dMsYf4CZS6w50r7hyzqyrwDoyNxkLnd2PdcHT/sym1QmflsjEs7pejtnohO6N2H
62+
wQW6M0H7Zt8claGRla4fKkg=
63+
-----END CERTIFICATE-----
64+
EOT
65+
encrypted_private_key = <<EOT
66+
-----BEGIN PRIVATE KEY-----
67+
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCA/Oj2HXqs5fTk
68+
j/8DrlOQtLG3K9RMsYHvnwICLxkGqVcTfut58hDFLbQM8C3C0ENAKitNJplC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xsQQe43cCC6WM7Cs
85+
Zdbu86dMkqzp+4BJfalHFDl0llp782D8Ybiy6CwZbvNyxptNIW7GYfZ9TVCllBMh
86+
5izIqbgub4DWNtq591l+Bf2BnmstU3uiagYw8awSBP4eo9p6y1IgkDafAoGBAJbi
87+
lIiqEP0IqA06/pWc0Qew3rD7OT0ndqjU6Es2i7xovURf3QDkinJThBZNbdYUzdsp
88+
IgloP9yY33/a90SNLLIYlARJtyNVZxK59X4qiOpF9prlfFvgpOumfbkj15JljTB8
89+
aGKkSvfVA5jRYwLysDwMCHwO0bOR1u3itos5AgsFAoGAKEGms1kuQ5/HyFgSmg9G
90+
wBUzu+5Y08/A37rvyXsR6GjmlZJvULEopJNUNCOOpITNQikXK63sIFry7/59eGv5
91+
UwKadZbfwbVF5ipu59UxfVE3lipf/mYePDqMkHVWv/8p+OnnJt9uKnyW8VSOu5uk
92+
82QF30zbIWDTUjrcugVAs+E=
93+
-----END PRIVATE KEY-----
94+
EOT
95+
}
96+
depends_on = [google_integrations_client.client]
97+
}
98+
# [END application_integration_create_auth_config_certificate]
99+
100+
# [START application_integration_create_auth_config_jwt]
101+
resource "google_integrations_auth_config" "auth_config_jwt" {
102+
location = "us-central1"
103+
display_name = "tf-jwt"
104+
description = "Test auth config created via terraform"
105+
decrypted_credential {
106+
credential_type = "JWT"
107+
jwt {
108+
jwt_header = "{\"alg\": \"HS256\", \"typ\": \"JWT\"}"
109+
jwt_payload = "{\"sub\": \"1234567890\", \"name\": \"John Doe\", \"iat\": 1516239022}"
110+
secret = "secret"
111+
}
112+
}
113+
depends_on = [google_integrations_client.client]
114+
}
115+
# [END application_integration_create_auth_config_jwt]
116+
117+
# [START application_integration_create_auth_config_oauth2_authorization_code]
118+
resource "google_integrations_auth_config" "auth_config_oauth2_authorization_code" {
119+
location = "us-central1"
120+
display_name = "tf-oauth2-authorization-code"
121+
description = "Test auth config created via terraform"
122+
decrypted_credential {
123+
credential_type = "OAUTH2_AUTHORIZATION_CODE"
124+
oauth2_authorization_code {
125+
client_id = "Kf7utRvgr95oGO5YMmhFOLo8"
126+
client_secret = "D-XXFDDMLrg2deDgczzHTBwC3p16wRK1rdKuuoFdWqO0wliJ"
127+
scope = "photo offline_access"
128+
auth_endpoint = "https://authorization-server.com/authorize"
129+
token_endpoint = "https://authorization-server.com/token"
130+
}
131+
}
132+
depends_on = [google_integrations_client.client]
133+
}
134+
# [END application_integration_create_auth_config_oauth2_authorization_code]
135+
136+
# [START application_integration_create_auth_config_oauth2_client_credentials]
137+
resource "google_integrations_auth_config" "auth_config_oauth2_client_credentials" {
138+
location = "us-central1"
139+
display_name = "tf-oauth2-client-credentials"
140+
description = "Test auth config created via terraform"
141+
decrypted_credential {
142+
credential_type = "OAUTH2_CLIENT_CREDENTIALS"
143+
oauth2_client_credentials {
144+
client_id = "demo-backend-client"
145+
client_secret = "MJlO3binatD9jk1"
146+
scope = "read"
147+
token_endpoint = "https://login-demo.curity.io/oauth/v2/oauth-token"
148+
request_type = "ENCODED_HEADER"
149+
token_params {
150+
entries {
151+
key {
152+
literal_value {
153+
string_value = "string-key"
154+
}
155+
}
156+
value {
157+
literal_value {
158+
string_value = "string-value"
159+
}
160+
}
161+
}
162+
}
163+
}
164+
}
165+
depends_on = [google_integrations_client.client]
166+
}
167+
# [END application_integration_create_auth_config_oauth2_client_credentials]

application_integration/main.tf renamed to application_integration/provision_region/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ data "google_project" "default" {
1818
}
1919

2020
# [START application_integration_edit_region]
21-
2221
resource "random_id" "default" {
2322
byte_length = 8
2423
}

0 commit comments

Comments
 (0)