Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key alias fix #950

Merged
merged 3 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions apis/kms/v1alpha1/zz_alias.go → apis/kms/v1alpha1/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Code generated by ack-generate. DO NOT EDIT.
// NOTE(muvaf): This code ported from ACK-generated code. See details here:
// https://github.com/crossplane/provider-aws/pull/950#issue-1055573793

package v1alpha1

Expand All @@ -29,16 +30,35 @@ type AliasParameters struct {
// Region is which region the Alias will be created.
// +kubebuilder:validation:Required
Region string `json:"region"`
// Specifies the alias name. This value must begin with alias/ followed by a
// name, such as alias/ExampleAlias.

// Associates the alias with the specified customer managed CMK (https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#customer-cmk).
// The CMK must be in the same AWS Region.
//
// The AliasName value must be string of 1-256 characters. It can contain only
// alphanumeric characters, forward slashes (/), underscores (_), and dashes
// (-). The alias name cannot begin with alias/aws/. The alias/aws/ prefix is
// reserved for AWS managed CMKs (https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-managed-cmk).
// +kubebuilder:validation:Required
AliasName *string `json:"aliasName"`
CustomAliasParameters `json:",inline"`
// A valid CMK ID is required. If you supply a null or empty string value, this
// operation returns an error.
//
// For help finding the key ID and ARN, see Finding the Key ID and ARN (https://docs.aws.amazon.com/kms/latest/developerguide/viewing-keys.html#find-cmk-id-arn)
// in the AWS Key Management Service Developer Guide.
//
// Specify the key ID or the Amazon Resource Name (ARN) of the CMK.
//
// For example:
//
// * Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
//
// * Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
//
// To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey.
// +crossplane:generate:reference:type=Key
TargetKeyID *string `json:"targetKeyId,omitempty"`

// TargetKeyIDRef is a reference to a KMS Key used to set TargetKeyID.
// +optional
TargetKeyIDRef *xpv1.Reference `json:"targetKeyIdRef,omitempty"`

// TargetKeyIDSelector selects a reference to a KMS Key used to set TargetKeyID.
// +optional
TargetKeyIDSelector *xpv1.Selector `json:"targetKeyIdSelector,omitempty"`
}

// AliasSpec defines the desired state of Alias
Expand Down
17 changes: 0 additions & 17 deletions apis/kms/v1alpha1/custom_types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package v1alpha1

import xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"

// CustomKeyParameters are custom parameters for Key.
type CustomKeyParameters struct {
// Specifies whether the CMK is enabled.
Expand All @@ -10,18 +8,3 @@ type CustomKeyParameters struct {
// Specifies how many days the Key is retained when scheduled for deletion. Defaults to 30 days.
PendingWindowInDays *int64 `json:"pendingWindowInDays,omitempty"`
}

// CustomAliasParameters are custom parameters for Alias.
type CustomAliasParameters struct {
// Associates the alias with the specified customer managed CMK (https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#customer-cmk). The CMK must be in the same AWS Region. \n A valid CMK ID is required. If you supply a null or empty string value, this operation returns an error. \n For help finding the key ID and ARN, see Finding the Key ID and ARN (https://docs.aws.amazon.com/kms/latest/developerguide/viewing-keys.html#find-cmk-id-arn) in the AWS Key Management Service Developer Guide. \n Specify the key ID or the Amazon Resource Name (ARN) of the CMK. \n For example: \n * Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab \n * Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab \n To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey.
// +optional
TargetKeyID *string `json:"targetKeyID,omitempty"`

// TargetKeyIDRef is a reference to a KMS Key used to set TargetKeyID.
// +optional
TargetKeyIDRef *xpv1.Reference `json:"targetKeyIDRef,omitempty"`

// TargetKeyIDSelector selects a reference to a KMS Key used to set TargetKeyID.
// +optional
TargetKeyIDSelector *xpv1.Selector `json:"targetKeyIDSelector,omitempty"`
}
8 changes: 1 addition & 7 deletions apis/kms/v1alpha1/generator-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ ignore:
resource_names:
- CustomKeyStore
- Grant
field_paths:
- CreateAliasInput.TargetKeyId
- Alias
resources:
Key:
exceptions:
Expand All @@ -12,8 +11,3 @@ resources:
# so the IsNotFound() function is generated correctly
404:
code: NotFoundException
Alias:
exceptions:
errors:
404:
code: NotFoundException
50 changes: 12 additions & 38 deletions apis/kms/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions apis/kms/v1alpha1/zz_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions examples/kms/alias.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
apiVersion: kms.aws.crossplane.io/v1alpha1
kind: Alias
metadata:
name: dev-key
name: dev-alias
spec:
forProvider:
region: us-east-1
aliasName: alias/dev-key
targetKeyIDRef:
targetKeyIdRef:
name: dev-key
providerConfigRef:
name: example
22 changes: 6 additions & 16 deletions package/crds/kms.aws.crossplane.io_aliases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.0
controller-gen.kubebuilder.io/version: v0.6.2
creationTimestamp: null
name: aliases.kms.aws.crossplane.io
spec:
Expand Down Expand Up @@ -60,20 +60,11 @@ spec:
forProvider:
description: AliasParameters defines the desired state of Alias
properties:
aliasName:
description: "Specifies the alias name. This value must begin
with alias/ followed by a name, such as alias/ExampleAlias.
\n The AliasName value must be string of 1-256 characters. It
can contain only alphanumeric characters, forward slashes (/),
underscores (_), and dashes (-). The alias name cannot begin
with alias/aws/. The alias/aws/ prefix is reserved for AWS managed
CMKs (https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-managed-cmk)."
type: string
region:
description: Region is which region the Alias will be created.
type: string
targetKeyID:
description: 'Associates the alias with the specified customer
targetKeyId:
description: "Associates the alias with the specified customer
managed CMK (https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#customer-cmk).
The CMK must be in the same AWS Region. \n A valid CMK ID is
required. If you supply a null or empty string value, this operation
Expand All @@ -84,9 +75,9 @@ spec:
For example: \n * Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
\n * Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
\n To get the key ID and key ARN for a CMK, use ListKeys or
DescribeKey.'
DescribeKey."
type: string
targetKeyIDRef:
targetKeyIdRef:
negz marked this conversation as resolved.
Show resolved Hide resolved
description: TargetKeyIDRef is a reference to a KMS Key used to
set TargetKeyID.
properties:
Expand All @@ -96,7 +87,7 @@ spec:
required:
- name
type: object
targetKeyIDSelector:
targetKeyIdSelector:
description: TargetKeyIDSelector selects a reference to a KMS
Key used to set TargetKeyID.
properties:
Expand All @@ -112,7 +103,6 @@ spec:
type: object
type: object
required:
- aliasName
- region
type: object
providerConfigRef:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Code generated by ack-generate. DO NOT EDIT.
// NOTE(muvaf): This code ported from ACK-generated code. See details here:
// https://github.com/crossplane/provider-aws/pull/950#issue-1055573793

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be worth a note somewhere to explain why this resource looks like generated code, but "isn't".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment to all those files pointing to description of this PR for details.

package alias

Expand Down
Loading