This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
/
openid_connect_identity_providers.go
88 lines (82 loc) · 3.65 KB
/
openid_connect_identity_providers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package iam
import (
"context"
"github.com/aws/aws-sdk-go-v2/service/iam"
"github.com/cloudquery/cq-provider-aws/client"
"github.com/cloudquery/cq-provider-sdk/provider/diag"
"github.com/cloudquery/cq-provider-sdk/provider/schema"
)
type IamOpenIdIdentityProviderWrapper struct {
*iam.GetOpenIDConnectProviderOutput
Arn string
}
func IamOpenidConnectIdentityProviders() *schema.Table {
return &schema.Table{
Name: "aws_iam_openid_connect_identity_providers",
Description: "IAM OIDC identity providers are entities in IAM that describe an external identity provider (IdP) service that supports the OpenID Connect (OIDC) standard, such as Google or Salesforce.",
Resolver: fetchIamOpenidConnectIdentityProviders,
Multiplex: client.AccountMultiplex,
IgnoreError: client.IgnoreCommonErrors,
DeleteFilter: client.DeleteAccountFilter,
Options: schema.TableCreationOptions{PrimaryKeys: []string{"arn"}},
IgnoreInTests: true,
Columns: []schema.Column{
{
Name: "account_id",
Description: "The AWS Account ID of the resource.",
Type: schema.TypeString,
Resolver: client.ResolveAWSAccount,
},
{
Name: "arn",
Description: "Amazon Resource Name (ARN) of the openid connect identity provider.",
Type: schema.TypeString,
},
{
Name: "client_id_list",
Description: "A list of client IDs (also known as audiences) that are associated with the specified IAM OIDC provider resource object. For more information, see CreateOpenIDConnectProvider. ",
Type: schema.TypeStringArray,
Resolver: schema.PathResolver("ClientIDList"),
},
{
Name: "create_date",
Description: "The date and time when the IAM OIDC provider resource object was created in the AWS account. ",
Type: schema.TypeTimestamp,
},
{
Name: "tags",
Description: "A list of tags that are attached to the specified IAM OIDC provider. The returned list of tags is sorted by tag key. For more information about tagging, see Tagging IAM resources (https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html) in the IAM User Guide. ",
Type: schema.TypeJSON,
Resolver: client.ResolveTags,
},
{
Name: "thumbprint_list",
Description: "A list of certificate thumbprints that are associated with the specified IAM OIDC provider resource object. For more information, see CreateOpenIDConnectProvider. ",
Type: schema.TypeStringArray,
},
{
Name: "url",
Description: "The URL that the IAM OIDC provider resource object is associated with. For more information, see CreateOpenIDConnectProvider. ",
Type: schema.TypeString,
},
},
}
}
// ====================================================================================================================
// Table Resolver Functions
// ====================================================================================================================
func fetchIamOpenidConnectIdentityProviders(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
svc := meta.(*client.Client).Services().IAM
response, err := svc.ListOpenIDConnectProviders(ctx, &iam.ListOpenIDConnectProvidersInput{})
if err != nil {
return diag.WrapError(err)
}
for _, p := range response.OpenIDConnectProviderList {
providerResponse, err := svc.GetOpenIDConnectProvider(ctx, &iam.GetOpenIDConnectProviderInput{OpenIDConnectProviderArn: p.Arn})
if err != nil {
return diag.WrapError(err)
}
res <- IamOpenIdIdentityProviderWrapper{providerResponse, *p.Arn}
}
return nil
}