sigs.k8s.io/cluster-api-provider-aws@v1.5.5/api/v1beta1/awsidentity_types.go (about)

     1  /*
     2  Copyright 2021 The Kubernetes Authors.
     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  package v1beta1
    18  
    19  import (
    20  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    21  )
    22  
    23  // AWSClusterIdentitySpec defines the Spec struct for AWSClusterIdentity types.
    24  type AWSClusterIdentitySpec struct {
    25  	// AllowedNamespaces is used to identify which namespaces are allowed to use the identity from.
    26  	// Namespaces can be selected either using an array of namespaces or with label selector.
    27  	// An empty allowedNamespaces object indicates that AWSClusters can use this identity from any namespace.
    28  	// If this object is nil, no namespaces will be allowed (default behaviour, if this field is not provided)
    29  	// A namespace should be either in the NamespaceList or match with Selector to use the identity.
    30  	//
    31  	// +optional
    32  	// +nullable
    33  	AllowedNamespaces *AllowedNamespaces `json:"allowedNamespaces"`
    34  }
    35  
    36  // AllowedNamespaces is a selector of namespaces that AWSClusters can
    37  // use this ClusterPrincipal from. This is a standard Kubernetes LabelSelector,
    38  // a label query over a set of resources. The result of matchLabels and
    39  // matchExpressions are ANDed.
    40  type AllowedNamespaces struct {
    41  	// An nil or empty list indicates that AWSClusters cannot use the identity from any namespace.
    42  	//
    43  	// +optional
    44  	// +nullable
    45  	NamespaceList []string `json:"list"`
    46  
    47  	// An empty selector indicates that AWSClusters cannot use this
    48  	// AWSClusterIdentity from any namespace.
    49  	// +optional
    50  	Selector metav1.LabelSelector `json:"selector"`
    51  }
    52  
    53  // AWSRoleSpec defines the specifications for all identities based around AWS roles.
    54  type AWSRoleSpec struct {
    55  	// The Amazon Resource Name (ARN) of the role to assume.
    56  	RoleArn string `json:"roleARN"`
    57  	// An identifier for the assumed role session
    58  	SessionName string `json:"sessionName,omitempty"`
    59  	// The duration, in seconds, of the role session before it is renewed.
    60  	// +kubebuilder:validation:Minimum:=900
    61  	// +kubebuilder:validation:Maximum:=43200
    62  	DurationSeconds int32 `json:"durationSeconds,omitempty"`
    63  	// An IAM policy as a JSON-encoded string that you want to use as an inline session policy.
    64  	InlinePolicy string `json:"inlinePolicy,omitempty"`
    65  
    66  	// The Amazon Resource Names (ARNs) of the IAM managed policies that you want
    67  	// to use as managed session policies.
    68  	// The policies must exist in the same account as the role.
    69  	PolicyARNs []string `json:"policyARNs,omitempty"`
    70  }
    71  
    72  // +kubebuilder:object:root=true
    73  // +kubebuilder:resource:path=awsclusterstaticidentities,scope=Cluster,categories=cluster-api,shortName=awssi
    74  // +kubebuilder:storageversion
    75  // +k8s:defaulter-gen=true
    76  
    77  // AWSClusterStaticIdentity is the Schema for the awsclusterstaticidentities API
    78  // It represents a reference to an AWS access key ID and secret access key, stored in a secret.
    79  type AWSClusterStaticIdentity struct {
    80  	metav1.TypeMeta   `json:",inline"`
    81  	metav1.ObjectMeta `json:"metadata,omitempty"`
    82  
    83  	// Spec for this AWSClusterStaticIdentity
    84  	Spec AWSClusterStaticIdentitySpec `json:"spec,omitempty"`
    85  }
    86  
    87  // +kubebuilder:object:root=true
    88  // +k8s:defaulter-gen=true
    89  
    90  // AWSClusterStaticIdentityList contains a list of AWSClusterStaticIdentity.
    91  type AWSClusterStaticIdentityList struct {
    92  	metav1.TypeMeta `json:",inline"`
    93  	metav1.ListMeta `json:"metadata,omitempty"`
    94  	Items           []AWSClusterStaticIdentity `json:"items"`
    95  }
    96  
    97  // AWSClusterStaticIdentitySpec defines the specifications for AWSClusterStaticIdentity.
    98  type AWSClusterStaticIdentitySpec struct {
    99  	AWSClusterIdentitySpec `json:",inline"`
   100  	// Reference to a secret containing the credentials. The secret should
   101  	// contain the following data keys:
   102  	//  AccessKeyID: AKIAIOSFODNN7EXAMPLE
   103  	//  SecretAccessKey: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
   104  	//  SessionToken: Optional
   105  	SecretRef string `json:"secretRef"`
   106  }
   107  
   108  // +kubebuilder:object:root=true
   109  // +kubebuilder:resource:path=awsclusterroleidentities,scope=Cluster,categories=cluster-api,shortName=awsri
   110  // +kubebuilder:storageversion
   111  // +k8s:defaulter-gen=true
   112  
   113  // AWSClusterRoleIdentity is the Schema for the awsclusterroleidentities API
   114  // It is used to assume a role using the provided sourceRef.
   115  type AWSClusterRoleIdentity struct {
   116  	metav1.TypeMeta   `json:",inline"`
   117  	metav1.ObjectMeta `json:"metadata,omitempty"`
   118  
   119  	// Spec for this AWSClusterRoleIdentity.
   120  	Spec AWSClusterRoleIdentitySpec `json:"spec,omitempty"`
   121  }
   122  
   123  // +kubebuilder:object:root=true
   124  // +k8s:defaulter-gen=true
   125  
   126  // AWSClusterRoleIdentityList contains a list of AWSClusterRoleIdentity.
   127  type AWSClusterRoleIdentityList struct {
   128  	metav1.TypeMeta `json:",inline"`
   129  	metav1.ListMeta `json:"metadata,omitempty"`
   130  	Items           []AWSClusterRoleIdentity `json:"items"`
   131  }
   132  
   133  // AWSClusterRoleIdentitySpec defines the specifications for AWSClusterRoleIdentity.
   134  type AWSClusterRoleIdentitySpec struct {
   135  	AWSClusterIdentitySpec `json:",inline"`
   136  	AWSRoleSpec            `json:",inline"`
   137  	// A unique identifier that might be required when you assume a role in another account.
   138  	// If the administrator of the account to which the role belongs provided you with an
   139  	// external ID, then provide that value in the ExternalId parameter. This value can be
   140  	// any string, such as a passphrase or account number. A cross-account role is usually
   141  	// set up to trust everyone in an account. Therefore, the administrator of the trusting
   142  	// account might send an external ID to the administrator of the trusted account. That
   143  	// way, only someone with the ID can assume the role, rather than everyone in the
   144  	// account. For more information about the external ID, see How to Use an External ID
   145  	// When Granting Access to Your AWS Resources to a Third Party in the IAM User Guide.
   146  	// +optional
   147  	ExternalID string `json:"externalID,omitempty"`
   148  
   149  	// SourceIdentityRef is a reference to another identity which will be chained to do
   150  	// role assumption. All identity types are accepted.
   151  	SourceIdentityRef *AWSIdentityReference `json:"sourceIdentityRef,omitempty"`
   152  }
   153  
   154  // +kubebuilder:object:root=true
   155  // +kubebuilder:resource:path=awsclustercontrolleridentities,scope=Cluster,categories=cluster-api,shortName=awsci
   156  // +kubebuilder:storageversion
   157  // +k8s:defaulter-gen=true
   158  
   159  // AWSClusterControllerIdentity is the Schema for the awsclustercontrolleridentities API
   160  // It is used to grant access to use Cluster API Provider AWS Controller credentials.
   161  type AWSClusterControllerIdentity struct {
   162  	metav1.TypeMeta   `json:",inline"`
   163  	metav1.ObjectMeta `json:"metadata,omitempty"`
   164  
   165  	// Spec for this AWSClusterControllerIdentity.
   166  	Spec AWSClusterControllerIdentitySpec `json:"spec,omitempty"`
   167  }
   168  
   169  // +kubebuilder:object:root=true
   170  // +k8s:defaulter-gen=true
   171  
   172  // AWSClusterControllerIdentityList contains a list of AWSClusterControllerIdentity.
   173  type AWSClusterControllerIdentityList struct {
   174  	metav1.TypeMeta `json:",inline"`
   175  	metav1.ListMeta `json:"metadata,omitempty"`
   176  	Items           []AWSClusterControllerIdentity `json:"items"`
   177  }
   178  
   179  // AWSClusterControllerIdentitySpec defines the specifications for AWSClusterControllerIdentity.
   180  type AWSClusterControllerIdentitySpec struct {
   181  	AWSClusterIdentitySpec `json:",inline"`
   182  }
   183  
   184  func init() {
   185  	SchemeBuilder.Register(
   186  		&AWSClusterStaticIdentity{},
   187  		&AWSClusterStaticIdentityList{},
   188  		&AWSClusterRoleIdentity{},
   189  		&AWSClusterRoleIdentityList{},
   190  		&AWSClusterControllerIdentity{},
   191  		&AWSClusterControllerIdentityList{},
   192  	)
   193  }