File: api_op_CreateAccessEntry.go

package info (click to toggle)
golang-github-aws-aws-sdk-go-v2 1.24.1-2~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 554,032 kB
  • sloc: java: 15,941; makefile: 419; sh: 175
file content (248 lines) | stat: -rw-r--r-- 10,217 bytes parent folder | download
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
// Code generated by smithy-go-codegen DO NOT EDIT.

package eks

import (
	"context"
	"fmt"
	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
	"github.com/aws/aws-sdk-go-v2/service/eks/types"
	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
)

// Creates an access entry. An access entry allows an IAM principal to access your
// cluster. Access entries can replace the need to maintain entries in the aws-auth
// ConfigMap for authentication. You have the following options for authorizing an
// IAM principal to access Kubernetes objects on your cluster: Kubernetes
// role-based access control (RBAC), Amazon EKS, or both. Kubernetes RBAC
// authorization requires you to create and manage Kubernetes Role , ClusterRole ,
// RoleBinding , and ClusterRoleBinding objects, in addition to managing access
// entries. If you use Amazon EKS authorization exclusively, you don't need to
// create and manage Kubernetes Role , ClusterRole , RoleBinding , and
// ClusterRoleBinding objects. For more information about access entries, see
// Access entries (https://docs.aws.amazon.com/eks/latest/userguide/access-entries.html)
// in the Amazon EKS User Guide.
func (c *Client) CreateAccessEntry(ctx context.Context, params *CreateAccessEntryInput, optFns ...func(*Options)) (*CreateAccessEntryOutput, error) {
	if params == nil {
		params = &CreateAccessEntryInput{}
	}

	result, metadata, err := c.invokeOperation(ctx, "CreateAccessEntry", params, optFns, c.addOperationCreateAccessEntryMiddlewares)
	if err != nil {
		return nil, err
	}

	out := result.(*CreateAccessEntryOutput)
	out.ResultMetadata = metadata
	return out, nil
}

type CreateAccessEntryInput struct {

	// The name of your cluster.
	//
	// This member is required.
	ClusterName *string

	// The ARN of the IAM principal for the AccessEntry . You can specify one ARN for
	// each access entry. You can't specify the same ARN in more than one access entry.
	// This value can't be changed after access entry creation. The valid principals
	// differ depending on the type of the access entry in the type field. The only
	// valid ARN is IAM roles for the types of access entries for nodes: . You can use
	// every IAM principal type for STANDARD access entries. You can't use the STS
	// session principal type with access entries because this is a temporary principal
	// for each session and not a permanent identity that can be assigned permissions.
	// IAM best practices (https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#bp-users-federation-idp)
	// recommend using IAM roles with temporary credentials, rather than IAM users with
	// long-term credentials.
	//
	// This member is required.
	PrincipalArn *string

	// A unique, case-sensitive identifier that you provide to ensure the idempotency
	// of the request.
	ClientRequestToken *string

	// The value for name that you've specified for kind: Group as a subject in a
	// Kubernetes RoleBinding or ClusterRoleBinding object. Amazon EKS doesn't confirm
	// that the value for name exists in any bindings on your cluster. You can specify
	// one or more names. Kubernetes authorizes the principalArn of the access entry
	// to access any cluster objects that you've specified in a Kubernetes Role or
	// ClusterRole object that is also specified in a binding's roleRef . For more
	// information about creating Kubernetes RoleBinding , ClusterRoleBinding , Role ,
	// or ClusterRole objects, see Using RBAC Authorization in the Kubernetes
	// documentation (https://kubernetes.io/docs/reference/access-authn-authz/rbac/) .
	// If you want Amazon EKS to authorize the principalArn (instead of, or in
	// addition to Kubernetes authorizing the principalArn ), you can associate one or
	// more access policies to the access entry using AssociateAccessPolicy . If you
	// associate any access policies, the principalARN has all permissions assigned in
	// the associated access policies and all permissions in any Kubernetes Role or
	// ClusterRole objects that the group names are bound to.
	KubernetesGroups []string

	// Metadata that assists with categorization and organization. Each tag consists
	// of a key and an optional value. You define both. Tags don't propagate to any
	// other cluster or Amazon Web Services resources.
	Tags map[string]string

	// The type of the new access entry. Valid values are Standard , FARGATE_LINUX ,
	// EC2_LINUX , and EC2_WINDOWS . If the principalArn is for an IAM role that's
	// used for self-managed Amazon EC2 nodes, specify EC2_LINUX or EC2_WINDOWS .
	// Amazon EKS grants the necessary permissions to the node for you. If the
	// principalArn is for any other purpose, specify STANDARD . If you don't specify a
	// value, Amazon EKS sets the value to STANDARD . It's unnecessary to create access
	// entries for IAM roles used with Fargate profiles or managed Amazon EC2 nodes,
	// because Amazon EKS creates entries in the aws-auth ConfigMap for the roles. You
	// can't change this value once you've created the access entry. If you set the
	// value to EC2_LINUX or EC2_WINDOWS , you can't specify values for
	// kubernetesGroups , or associate an AccessPolicy to the access entry.
	Type *string

	// The username to authenticate to Kubernetes with. We recommend not specifying a
	// username and letting Amazon EKS specify it for you. For more information about
	// the value Amazon EKS specifies for you, or constraints before specifying your
	// own username, see Creating access entries (https://docs.aws.amazon.com/eks/latest/userguide/access-entries.html#creating-access-entries)
	// in the Amazon EKS User Guide.
	Username *string

	noSmithyDocumentSerde
}

type CreateAccessEntryOutput struct {

	// An access entry allows an IAM principal (user or role) to access your cluster.
	// Access entries can replace the need to maintain the aws-auth ConfigMap for
	// authentication. For more information about access entries, see Access entries (https://docs.aws.amazon.com/eks/latest/userguide/access-entries.html)
	// in the Amazon EKS User Guide.
	AccessEntry *types.AccessEntry

	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (c *Client) addOperationCreateAccessEntryMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
		return err
	}
	err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateAccessEntry{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateAccessEntry{}, middleware.After)
	if err != nil {
		return err
	}
	if err := addProtocolFinalizerMiddlewares(stack, options, "CreateAccessEntry"); err != nil {
		return fmt.Errorf("add protocol finalizers: %v", err)
	}

	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
		return err
	}
	if err = addSetLoggerMiddleware(stack, options); err != nil {
		return err
	}
	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
		return err
	}
	if err = addResolveEndpointMiddleware(stack, options); err != nil {
		return err
	}
	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
		return err
	}
	if err = addRetryMiddlewares(stack, options); err != nil {
		return err
	}
	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
		return err
	}
	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
		return err
	}
	if err = addClientUserAgent(stack, options); err != nil {
		return err
	}
	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
		return err
	}
	if err = addIdempotencyToken_opCreateAccessEntryMiddleware(stack, options); err != nil {
		return err
	}
	if err = addOpCreateAccessEntryValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateAccessEntry(options.Region), middleware.Before); err != nil {
		return err
	}
	if err = awsmiddleware.AddRecursionDetection(stack); err != nil {
		return err
	}
	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
		return err
	}
	if err = addResponseErrorMiddleware(stack); err != nil {
		return err
	}
	if err = addRequestResponseLogging(stack, options); err != nil {
		return err
	}
	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
		return err
	}
	return nil
}

type idempotencyToken_initializeOpCreateAccessEntry struct {
	tokenProvider IdempotencyTokenProvider
}

func (*idempotencyToken_initializeOpCreateAccessEntry) ID() string {
	return "OperationIdempotencyTokenAutoFill"
}

func (m *idempotencyToken_initializeOpCreateAccessEntry) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
	if m.tokenProvider == nil {
		return next.HandleInitialize(ctx, in)
	}

	input, ok := in.Parameters.(*CreateAccessEntryInput)
	if !ok {
		return out, metadata, fmt.Errorf("expected middleware input to be of type *CreateAccessEntryInput ")
	}

	if input.ClientRequestToken == nil {
		t, err := m.tokenProvider.GetIdempotencyToken()
		if err != nil {
			return out, metadata, err
		}
		input.ClientRequestToken = &t
	}
	return next.HandleInitialize(ctx, in)
}
func addIdempotencyToken_opCreateAccessEntryMiddleware(stack *middleware.Stack, cfg Options) error {
	return stack.Initialize.Add(&idempotencyToken_initializeOpCreateAccessEntry{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before)
}

func newServiceMetadataMiddleware_opCreateAccessEntry(region string) *awsmiddleware.RegisterServiceMetadata {
	return &awsmiddleware.RegisterServiceMetadata{
		Region:        region,
		ServiceID:     ServiceID,
		OperationName: "CreateAccessEntry",
	}
}