sigs.k8s.io/cluster-api-provider-aws@v1.5.5/api/v1alpha4/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 v1alpha4 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 // +k8s:defaulter-gen=true 75 76 // AWSClusterStaticIdentity is the Schema for the awsclusterstaticidentities API 77 // It represents a reference to an AWS access key ID and secret access key, stored in a secret. 78 type AWSClusterStaticIdentity struct { 79 metav1.TypeMeta `json:",inline"` 80 metav1.ObjectMeta `json:"metadata,omitempty"` 81 82 // Spec for this AWSClusterStaticIdentity 83 Spec AWSClusterStaticIdentitySpec `json:"spec,omitempty"` 84 } 85 86 // +kubebuilder:object:root=true 87 // +k8s:defaulter-gen=true 88 89 // AWSClusterStaticIdentityList contains a list of AWSClusterStaticIdentity. 90 type AWSClusterStaticIdentityList struct { 91 metav1.TypeMeta `json:",inline"` 92 metav1.ListMeta `json:"metadata,omitempty"` 93 Items []AWSClusterStaticIdentity `json:"items"` 94 } 95 96 // AWSClusterStaticIdentitySpec defines the specifications for AWSClusterStaticIdentity. 97 type AWSClusterStaticIdentitySpec struct { 98 AWSClusterIdentitySpec `json:",inline"` 99 // Reference to a secret containing the credentials. The secret should 100 // contain the following data keys: 101 // AccessKeyID: AKIAIOSFODNN7EXAMPLE 102 // SecretAccessKey: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY 103 // SessionToken: Optional 104 SecretRef string `json:"secretRef"` 105 } 106 107 // +kubebuilder:object:root=true 108 // +kubebuilder:resource:path=awsclusterroleidentities,scope=Cluster,categories=cluster-api,shortName=awsri 109 // +k8s:defaulter-gen=true 110 111 // AWSClusterRoleIdentity is the Schema for the awsclusterroleidentities API 112 // It is used to assume a role using the provided sourceRef. 113 type AWSClusterRoleIdentity struct { 114 metav1.TypeMeta `json:",inline"` 115 metav1.ObjectMeta `json:"metadata,omitempty"` 116 117 // Spec for this AWSClusterRoleIdentity. 118 Spec AWSClusterRoleIdentitySpec `json:"spec,omitempty"` 119 } 120 121 // +kubebuilder:object:root=true 122 // +k8s:defaulter-gen=true 123 124 // AWSClusterRoleIdentityList contains a list of AWSClusterRoleIdentity. 125 type AWSClusterRoleIdentityList struct { 126 metav1.TypeMeta `json:",inline"` 127 metav1.ListMeta `json:"metadata,omitempty"` 128 Items []AWSClusterRoleIdentity `json:"items"` 129 } 130 131 // AWSClusterRoleIdentitySpec defines the specifications for AWSClusterRoleIdentity. 132 type AWSClusterRoleIdentitySpec struct { 133 AWSClusterIdentitySpec `json:",inline"` 134 AWSRoleSpec `json:",inline"` 135 // A unique identifier that might be required when you assume a role in another account. 136 // If the administrator of the account to which the role belongs provided you with an 137 // external ID, then provide that value in the ExternalId parameter. This value can be 138 // any string, such as a passphrase or account number. A cross-account role is usually 139 // set up to trust everyone in an account. Therefore, the administrator of the trusting 140 // account might send an external ID to the administrator of the trusted account. That 141 // way, only someone with the ID can assume the role, rather than everyone in the 142 // account. For more information about the external ID, see How to Use an External ID 143 // When Granting Access to Your AWS Resources to a Third Party in the IAM User Guide. 144 // +optional 145 ExternalID string `json:"externalID,omitempty"` 146 147 // SourceIdentityRef is a reference to another identity which will be chained to do 148 // role assumption. All identity types are accepted. 149 SourceIdentityRef *AWSIdentityReference `json:"sourceIdentityRef,omitempty"` 150 } 151 152 // +kubebuilder:object:root=true 153 // +kubebuilder:resource:path=awsclustercontrolleridentities,scope=Cluster,categories=cluster-api,shortName=awsci 154 // +k8s:defaulter-gen=true 155 156 // AWSClusterControllerIdentity is the Schema for the awsclustercontrolleridentities API 157 // It is used to grant access to use Cluster API Provider AWS Controller credentials. 158 type AWSClusterControllerIdentity struct { 159 metav1.TypeMeta `json:",inline"` 160 metav1.ObjectMeta `json:"metadata,omitempty"` 161 162 // Spec for this AWSClusterControllerIdentity. 163 Spec AWSClusterControllerIdentitySpec `json:"spec,omitempty"` 164 } 165 166 // +kubebuilder:object:root=true 167 168 // AWSClusterControllerIdentityList contains a list of AWSClusterControllerIdentity. 169 type AWSClusterControllerIdentityList struct { 170 metav1.TypeMeta `json:",inline"` 171 metav1.ListMeta `json:"metadata,omitempty"` 172 Items []AWSClusterControllerIdentity `json:"items"` 173 } 174 175 // AWSClusterControllerIdentitySpec defines the specifications for AWSClusterControllerIdentity. 176 type AWSClusterControllerIdentitySpec struct { 177 AWSClusterIdentitySpec `json:",inline"` 178 } 179 180 func init() { 181 SchemeBuilder.Register( 182 &AWSClusterStaticIdentity{}, 183 &AWSClusterStaticIdentityList{}, 184 &AWSClusterRoleIdentity{}, 185 &AWSClusterRoleIdentityList{}, 186 &AWSClusterControllerIdentity{}, 187 &AWSClusterControllerIdentityList{}, 188 ) 189 }