Skip to content

Commit 2a7c873

Browse files
committed
Support IntegrationV1 in terraform provider
* Updated the audience field docs and validation error message to clarify what values are supported. * Updated subkind validation error message when marshaling an IntegrationV1 to clarify what values are supported.
1 parent fd95186 commit 2a7c873

File tree

25 files changed

+2611
-18
lines changed

25 files changed

+2611
-18
lines changed

api/proto/teleport/legacy/types/types.proto

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8688,7 +8688,7 @@ message AWSOIDCIntegrationSpecV1 {
86888688
// This bucket/prefix/* files must be publicly accessible and contain the following:
86898689
// > .well-known/openid-configuration
86908690
// > .well-known/jwks
8691-
// Format: s3://<bucket>/<prefix>
8691+
// Format: `s3://<bucket>/<prefix>`
86928692
// Optional. The proxy's endpoint is used if it is not specified.
86938693
//
86948694
// DEPRECATED: Thumbprint validation requires the issuer to update the IdP in AWS everytime the issuer changes the certificate.
@@ -8700,9 +8700,9 @@ message AWSOIDCIntegrationSpecV1 {
87008700
deprecated = true
87018701
];
87028702

8703-
// Audience is used to record a name of a plugin or a discover service in Teleport
8704-
// that depends on this integration.
8705-
// Audience value can be empty or configured with supported preset audience type.
8703+
// Audience is used to record a name of a plugin or a discover service in
8704+
// Teleport that depends on this integration.
8705+
// Audience value can either be empty or "aws-identity-center".
87068706
// Preset audience may impose specific behavior on the integration CRUD API,
87078707
// such as preventing integration from update or deletion. Empty audience value
87088708
// should be treated as a default and backward-compatible behavior of the integration.

api/types/integration.go

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"encoding/json"
2121
"fmt"
2222
"net/url"
23+
"slices"
2324

2425
"github.com/gravitational/trace"
2526
"google.golang.org/protobuf/encoding/protojson"
@@ -42,6 +43,14 @@ const (
4243
IntegrationSubKindAWSRolesAnywhere = "aws-ra"
4344
)
4445

46+
// integrationSubKindValues is a list of supported integration subkind values.
47+
var integrationSubKindValues = []string{
48+
IntegrationSubKindAWSOIDC,
49+
IntegrationSubKindAzureOIDC,
50+
IntegrationSubKindAWSRolesAnywhere,
51+
IntegrationSubKindGitHub,
52+
}
53+
4554
const (
4655
// IntegrationAWSOIDCAudienceUnspecified denotes an empty audience value. Empty audience value
4756
// is used to maintain default OIDC integration behavior and backward compatibility.
@@ -50,6 +59,14 @@ const (
5059
IntegrationAWSOIDCAudienceAWSIdentityCenter = "aws-identity-center"
5160
)
5261

62+
// integrationAWSOIDCAudienceValues is a list of the supported AWS OIDC Audience
63+
// values. If this list is updated, be sure to also update the audience field's
64+
// godoc string in the [AWSOIDCIntegrationSpecV1] protobuf definition.
65+
var integrationAWSOIDCAudienceValues = []string{
66+
IntegrationAWSOIDCAudienceUnspecified,
67+
IntegrationAWSOIDCAudienceAWSIdentityCenter,
68+
}
69+
5370
const (
5471
// IntegrationAWSRolesAnywhereProfileSyncStatusSuccess indicates that the profile sync was successful.
5572
IntegrationAWSRolesAnywhereProfileSyncStatusSuccess = "SUCCESS"
@@ -300,12 +317,13 @@ func (s *IntegrationSpecV1_AWSOIDC) CheckAndSetDefaults() error {
300317
// ValidateAudience validates if the audience field is configured with
301318
// a supported audience value.
302319
func (s *IntegrationSpecV1_AWSOIDC) ValidateAudience() error {
303-
switch s.AWSOIDC.Audience {
304-
case IntegrationAWSOIDCAudienceUnspecified, IntegrationAWSOIDCAudienceAWSIdentityCenter:
305-
return nil
306-
default:
307-
return trace.BadParameter("unsupported audience value %q", s.AWSOIDC.Audience)
320+
if !slices.Contains(integrationAWSOIDCAudienceValues, s.AWSOIDC.Audience) {
321+
return trace.BadParameter("unsupported audience value %q, supported values are %q",
322+
s.AWSOIDC.Audience,
323+
integrationAWSOIDCAudienceValues,
324+
)
308325
}
326+
return nil
309327
}
310328

311329
// Validate validates the configuration for Azure OIDC integration subkind.
@@ -615,7 +633,7 @@ func (ig *IntegrationV1) MarshalJSON() ([]byte, error) {
615633
}
616634
d.Spec.AWSRA = *ig.GetAWSRolesAnywhereIntegrationSpec()
617635
default:
618-
return nil, trace.BadParameter("invalid subkind %q", ig.SubKind)
636+
return nil, trace.BadParameter("invalid subkind %q, supported values are %q", ig.SubKind, integrationSubKindValues)
619637
}
620638

621639
out, err := json.Marshal(d)

api/types/integration_test.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package types
1818

1919
import (
2020
"encoding/json"
21+
"strings"
2122
"testing"
2223

2324
"github.com/google/uuid"
@@ -68,6 +69,10 @@ func TestIntegrationJSONMarshalCycle(t *testing.T) {
6869
require.Equal(t, &ig2, ig)
6970
})
7071
}
72+
73+
aws.SubKind = ""
74+
_, err = json.MarshalIndent(aws, "", " ")
75+
require.ErrorContains(t, err, `invalid subkind "", supported values are ["aws-oidc" "azure-oidc" "aws-ra" "github"]`)
7176
}
7277

7378
func TestIntegrationCheckAndSetDefaults(t *testing.T) {
@@ -223,7 +228,12 @@ func TestIntegrationCheckAndSetDefaults(t *testing.T) {
223228
},
224229
)
225230
},
226-
expectedErrorIs: trace.IsBadParameter,
231+
expectedErrorIs: func(err error) bool {
232+
return trace.IsBadParameter(err) &&
233+
strings.Contains(err.Error(),
234+
`unsupported audience value "testvalue", supported values are ["" "aws-identity-center"]`,
235+
)
236+
},
227237
},
228238
{
229239
name: "azure-oidc: valid",
@@ -468,8 +478,8 @@ func TestIntegrationCheckAndSetDefaults(t *testing.T) {
468478
t.Run(tt.name, func(t *testing.T) {
469479
name := uuid.NewString()
470480
ig, err := tt.integration(name)
471-
require.True(t, tt.expectedErrorIs(err), "expected another error", err)
472-
if err != nil {
481+
require.True(t, tt.expectedErrorIs(err), "expected another error %v", err)
482+
if err != nil && trace.IsBadParameter(err) {
473483
return
474484
}
475485

api/types/types.pb.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/pages/reference/infrastructure-as-code/terraform-provider/data-sources/data-sources.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ The Teleport Terraform provider supports the following data-sources:
2727
- [`teleport_github_connector`](./github_connector.mdx)
2828
- [`teleport_health_check_config`](./health_check_config.mdx)
2929
- [`teleport_installer`](./installer.mdx)
30+
- [`teleport_integration`](./integration.mdx)
3031
- [`teleport_login_rule`](./login_rule.mdx)
3132
- [`teleport_oidc_connector`](./oidc_connector.mdx)
3233
- [`teleport_okta_import_rule`](./okta_import_rule.mdx)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: Reference for the teleport_integration Terraform data-source
3+
sidebar_label: integration
4+
description: This page describes the supported values of the teleport_integration data-source of the Teleport Terraform provider.
5+
---
6+
7+
{/*Auto-generated file. Do not edit.*/}
8+
{/*To regenerate, navigate to integrations/terraform and run `make docs`.*/}
9+
10+
This page describes the supported values of the `teleport_integration` data source of the
11+
Teleport Terraform provider.
12+
13+
14+
15+
16+
17+
{/* schema generated by tfplugindocs */}
18+
## Schema
19+
20+
### Required
21+
22+
- `metadata` (Attributes) Metadata is resource metadata (see [below for nested schema](#nested-schema-for-metadata))
23+
- `spec` (Attributes) Spec is an Integration specification. (see [below for nested schema](#nested-schema-for-spec))
24+
- `sub_kind` (String) SubKind is an optional resource sub kind, used in some resources
25+
- `version` (String) Version is the API version used to create the resource. It must be specified. Based on this version, Teleport will apply different defaults on resource creation or deletion. It must be an integer prefixed by "v". For example: `v1`
26+
27+
### Nested Schema for `metadata`
28+
29+
Required:
30+
31+
- `name` (String) Name is an object name
32+
33+
Optional:
34+
35+
- `description` (String) Description is object description
36+
- `expires` (String) Expires is a global expiry time header can be set on any resource in the system.
37+
- `labels` (Map of String) Labels is a set of labels
38+
39+
40+
### Nested Schema for `spec`
41+
42+
Optional:
43+
44+
- `aws_oidc` (Attributes) AWSOIDC contains the specific fields to handle the AWS OIDC Integration subkind (see [below for nested schema](#nested-schema-for-specaws_oidc))
45+
- `aws_ra` (Attributes) AWSRA contains the specific fields to handle the AWS Roles Anywhere Integration subkind. (see [below for nested schema](#nested-schema-for-specaws_ra))
46+
- `azure_oidc` (Attributes) AzureOIDC contains the specific fields to handle the Azure OIDC Integration subkind (see [below for nested schema](#nested-schema-for-specazure_oidc))
47+
48+
### Nested Schema for `spec.aws_oidc`
49+
50+
Optional:
51+
52+
- `audience` (String) Audience is used to record a name of a plugin or a discover service in Teleport that depends on this integration. Audience value can either be empty or "aws-identity-center". Preset audience may impose specific behavior on the integration CRUD API, such as preventing integration from update or deletion. Empty audience value should be treated as a default and backward-compatible behavior of the integration.
53+
- `issuer_s3_uri` (String) IssuerS3URI is the Identity Provider that was configured in AWS. This bucket/prefix/* files must be publicly accessible and contain the following: > .well-known/openid-configuration > .well-known/jwks Format: `s3://<bucket>/<prefix>` Optional. The proxy's endpoint is used if it is not specified. DEPRECATED: Thumbprint validation requires the issuer to update the IdP in AWS everytime the issuer changes the certificate. Amazon had some whitelisted providers where the thumbprint was ignored. S3 hosted providers was in that list. Amazon is now trusting all the root certificate authorities, and this workaround is no longer needed. DELETE IN 18.0.
54+
- `role_arn` (String) RoleARN contains the Role ARN used to set up the Integration. This is the AWS Role that Teleport will use to issue tokens for API Calls.
55+
56+
57+
### Nested Schema for `spec.aws_ra`
58+
59+
Optional:
60+
61+
- `profile_sync_config` (Attributes) ProfileSyncConfig contains the configuration for the AWS Roles Anywhere Profile sync. This is used to create AWS Roles Anywhere profiles as application servers. (see [below for nested schema](#nested-schema-for-specaws_raprofile_sync_config))
62+
- `trust_anchor_arn` (String) TrustAnchorARN contains the AWS IAM Roles Anywhere Trust Anchor ARN used to set up the Integration.
63+
64+
### Nested Schema for `spec.aws_ra.profile_sync_config`
65+
66+
Optional:
67+
68+
- `enabled` (Boolean) Enabled is set to true if this integration should sync profiles as application servers.
69+
- `profile_accepts_role_session_name` (Boolean) ProfileAcceptsRoleSessionName indicates whether the profile accepts a custom Role Session name.
70+
- `profile_arn` (String) ProfileARN is the ARN of the Roles Anywhere Profile used to generate credentials to access the AWS APIs.
71+
- `profile_name_filters` (List of String) ProfileNameFilters is a list of filters applied to the profile name. Only matching profiles will be synchronized as application servers. If empty, no filtering is applied. Filters can be globs, for example: profile* *name* Or regexes if they're prefixed and suffixed with ^ and $, for example: ^profile.*$ ^.*name.*$
72+
- `role_arn` (String) RoleARN is the ARN of the IAM Role to assume when accessing the AWS APIs.
73+
74+
75+
76+
### Nested Schema for `spec.azure_oidc`
77+
78+
Optional:
79+
80+
- `client_id` (String) ClientID specifies the ID of Azure enterprise application (client) that corresponds to this plugin.
81+
- `tenant_id` (String) TenantID specifies the ID of Entra Tenant (Directory) that this plugin integrates with.
82+
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
---
2+
title: Reference for the teleport_integration Terraform resource
3+
sidebar_label: integration
4+
description: This page describes the supported values of the teleport_integration resource of the Teleport Terraform provider.
5+
---
6+
7+
{/*Auto-generated file. Do not edit.*/}
8+
{/*To regenerate, navigate to integrations/terraform and run `make docs`.*/}
9+
10+
This page describes the supported values of the teleport_integration resource of the Teleport Terraform provider.
11+
12+
13+
14+
15+
## Example Usage
16+
17+
```hcl
18+
resource "teleport_integration" "aws_oidc" {
19+
version = "v1"
20+
sub_kind = "aws-oidc"
21+
metadata = {
22+
name = "example"
23+
description = "AWS OIDC integration"
24+
labels = {
25+
env = "dev"
26+
}
27+
}
28+
29+
spec = {
30+
aws_oidc = {
31+
role_arn = "arn:aws:iam::123456789012:role/example-role-name"
32+
}
33+
}
34+
}
35+
36+
resource "teleport_integration" "azure_oidc" {
37+
version = "v1"
38+
sub_kind = "azure-oidc"
39+
metadata = {
40+
name = "azure-oidc"
41+
description = "Example Azure OIDC integration"
42+
labels = {
43+
env = "dev"
44+
}
45+
}
46+
47+
spec = {
48+
azure_oidc = {
49+
// Azure Entra ID tenant ID
50+
tenant_id = "a1b2c3d4-f2e4-97a8-9abc-1234567890ab"
51+
// Azure enterprise application client ID
52+
client_id = "7f12e3b5-6789-4abc-def0-112233445566"
53+
}
54+
}
55+
}
56+
57+
resource "teleport_integration" "aws_roles_anywhere" {
58+
version = "v1"
59+
sub_kind = "aws-ra"
60+
metadata = {
61+
name = "aws-ra"
62+
description = "Example AWS Roles Anywhere integration"
63+
labels = {
64+
env = "dev"
65+
}
66+
}
67+
68+
spec = {
69+
aws_ra = {
70+
profile_sync_config = {
71+
// sync AWS profiles as Teleport applications
72+
enabled = true
73+
profile_accepts_role_session_name = false
74+
profile_arn = "arn:aws:rolesanywhere:us-east-1:123456789012:profile/<random-uuid>"
75+
role_arn = "arn:aws:iam::123456789012:role/example-role-name"
76+
// only sync AWS profiles as Teleport applications if the profile name matches
77+
profile_name_filters = [
78+
"teleport-*", // supports globs
79+
"^teleport-.*$", // and regex if the string is enclosed in regex anchors
80+
]
81+
}
82+
trust_anchor_arn = "arn:aws:rolesanywhere:us-east-1:123456789012:trust-anchor/<random-uuid>"
83+
}
84+
}
85+
}
86+
```
87+
88+
{/* schema generated by tfplugindocs */}
89+
## Schema
90+
91+
### Required
92+
93+
- `metadata` (Attributes) Metadata is resource metadata (see [below for nested schema](#nested-schema-for-metadata))
94+
- `spec` (Attributes) Spec is an Integration specification. (see [below for nested schema](#nested-schema-for-spec))
95+
- `sub_kind` (String) SubKind is an optional resource sub kind, used in some resources
96+
- `version` (String) Version is the API version used to create the resource. It must be specified. Based on this version, Teleport will apply different defaults on resource creation or deletion. It must be an integer prefixed by "v". For example: `v1`
97+
98+
### Nested Schema for `metadata`
99+
100+
Required:
101+
102+
- `name` (String) Name is an object name
103+
104+
Optional:
105+
106+
- `description` (String) Description is object description
107+
- `expires` (String) Expires is a global expiry time header can be set on any resource in the system.
108+
- `labels` (Map of String) Labels is a set of labels
109+
110+
111+
### Nested Schema for `spec`
112+
113+
Optional:
114+
115+
- `aws_oidc` (Attributes) AWSOIDC contains the specific fields to handle the AWS OIDC Integration subkind (see [below for nested schema](#nested-schema-for-specaws_oidc))
116+
- `aws_ra` (Attributes) AWSRA contains the specific fields to handle the AWS Roles Anywhere Integration subkind. (see [below for nested schema](#nested-schema-for-specaws_ra))
117+
- `azure_oidc` (Attributes) AzureOIDC contains the specific fields to handle the Azure OIDC Integration subkind (see [below for nested schema](#nested-schema-for-specazure_oidc))
118+
119+
### Nested Schema for `spec.aws_oidc`
120+
121+
Optional:
122+
123+
- `audience` (String) Audience is used to record a name of a plugin or a discover service in Teleport that depends on this integration. Audience value can either be empty or "aws-identity-center". Preset audience may impose specific behavior on the integration CRUD API, such as preventing integration from update or deletion. Empty audience value should be treated as a default and backward-compatible behavior of the integration.
124+
- `issuer_s3_uri` (String) IssuerS3URI is the Identity Provider that was configured in AWS. This bucket/prefix/* files must be publicly accessible and contain the following: > .well-known/openid-configuration > .well-known/jwks Format: `s3://<bucket>/<prefix>` Optional. The proxy's endpoint is used if it is not specified. DEPRECATED: Thumbprint validation requires the issuer to update the IdP in AWS everytime the issuer changes the certificate. Amazon had some whitelisted providers where the thumbprint was ignored. S3 hosted providers was in that list. Amazon is now trusting all the root certificate authorities, and this workaround is no longer needed. DELETE IN 18.0.
125+
- `role_arn` (String) RoleARN contains the Role ARN used to set up the Integration. This is the AWS Role that Teleport will use to issue tokens for API Calls.
126+
127+
128+
### Nested Schema for `spec.aws_ra`
129+
130+
Optional:
131+
132+
- `profile_sync_config` (Attributes) ProfileSyncConfig contains the configuration for the AWS Roles Anywhere Profile sync. This is used to create AWS Roles Anywhere profiles as application servers. (see [below for nested schema](#nested-schema-for-specaws_raprofile_sync_config))
133+
- `trust_anchor_arn` (String) TrustAnchorARN contains the AWS IAM Roles Anywhere Trust Anchor ARN used to set up the Integration.
134+
135+
### Nested Schema for `spec.aws_ra.profile_sync_config`
136+
137+
Optional:
138+
139+
- `enabled` (Boolean) Enabled is set to true if this integration should sync profiles as application servers.
140+
- `profile_accepts_role_session_name` (Boolean) ProfileAcceptsRoleSessionName indicates whether the profile accepts a custom Role Session name.
141+
- `profile_arn` (String) ProfileARN is the ARN of the Roles Anywhere Profile used to generate credentials to access the AWS APIs.
142+
- `profile_name_filters` (List of String) ProfileNameFilters is a list of filters applied to the profile name. Only matching profiles will be synchronized as application servers. If empty, no filtering is applied. Filters can be globs, for example: profile* *name* Or regexes if they're prefixed and suffixed with ^ and $, for example: ^profile.*$ ^.*name.*$
143+
- `role_arn` (String) RoleARN is the ARN of the IAM Role to assume when accessing the AWS APIs.
144+
145+
146+
147+
### Nested Schema for `spec.azure_oidc`
148+
149+
Optional:
150+
151+
- `client_id` (String) ClientID specifies the ID of Azure enterprise application (client) that corresponds to this plugin.
152+
- `tenant_id` (String) TenantID specifies the ID of Entra Tenant (Directory) that this plugin integrates with.

0 commit comments

Comments
 (0)