From a1af34e7ef8f66047cf9d8671afc7921aa960bc3 Mon Sep 17 00:00:00 2001 From: vaspahomov Date: Tue, 24 May 2022 19:26:08 +0500 Subject: [PATCH] add EgressOnlyInternetGateway resource Signed-off-by: vaspahomov --- .../zz_egressonlyinternetgateway_types.go | 104 +++++++ apis/ec2/v1alpha2/zz_generated.deepcopy.go | 188 +++++++++++++ apis/ec2/v1alpha2/zz_generated.managed.go | 66 +++++ apis/ec2/v1alpha2/zz_generated.managedlist.go | 9 + apis/ec2/v1alpha2/zz_generated.resolvers.go | 44 +++ apis/ec2/v1alpha2/zz_generated_terraformed.go | 74 +++++ apis/ec2/v1alpha2/zz_routetable_types.go | 7 + config/ec2/config.go | 8 + config/provider.go | 1 + .../zz_controller.go | 63 +++++ internal/controller/zz_setup.go | 2 + ...ssplane.io_egressonlyinternetgateways.yaml | 259 ++++++++++++++++++ ...ec2.aws.jet.crossplane.io_routetables.yaml | 24 ++ 13 files changed, 849 insertions(+) create mode 100755 apis/ec2/v1alpha2/zz_egressonlyinternetgateway_types.go create mode 100755 internal/controller/ec2/egressonlyinternetgateway/zz_controller.go create mode 100644 package/crds/ec2.aws.jet.crossplane.io_egressonlyinternetgateways.yaml diff --git a/apis/ec2/v1alpha2/zz_egressonlyinternetgateway_types.go b/apis/ec2/v1alpha2/zz_egressonlyinternetgateway_types.go new file mode 100755 index 000000000..760c3dafc --- /dev/null +++ b/apis/ec2/v1alpha2/zz_egressonlyinternetgateway_types.go @@ -0,0 +1,104 @@ +/* +Copyright 2021 The Crossplane Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by terrajet. DO NOT EDIT. + +package v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + v1 "github.com/crossplane/crossplane-runtime/apis/common/v1" +) + +type EgressOnlyInternetGatewayObservation struct { + ID *string `json:"id,omitempty" tf:"id,omitempty"` + + TagsAll map[string]*string `json:"tagsAll,omitempty" tf:"tags_all,omitempty"` +} + +type EgressOnlyInternetGatewayParameters struct { + + // Region is the region you'd like your resource to be created in. + // +terrajet:crd:field:TFTag=- + // +kubebuilder:validation:Required + Region *string `json:"region" tf:"-"` + + // +kubebuilder:validation:Optional + Tags map[string]*string `json:"tags,omitempty" tf:"tags,omitempty"` + + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-jet-aws/apis/ec2/v1alpha2.VPC + // +crossplane:generate:reference:refFieldName=VpcIdRef + // +crossplane:generate:reference:selectorFieldName=VpcIdSelector + // +kubebuilder:validation:Optional + VPCID *string `json:"vpcId,omitempty" tf:"vpc_id,omitempty"` + + // +kubebuilder:validation:Optional + VpcIdRef *v1.Reference `json:"vpcIdRef,omitempty" tf:"-"` + + // +kubebuilder:validation:Optional + VpcIdSelector *v1.Selector `json:"vpcIdSelector,omitempty" tf:"-"` +} + +// EgressOnlyInternetGatewaySpec defines the desired state of EgressOnlyInternetGateway +type EgressOnlyInternetGatewaySpec struct { + v1.ResourceSpec `json:",inline"` + ForProvider EgressOnlyInternetGatewayParameters `json:"forProvider"` +} + +// EgressOnlyInternetGatewayStatus defines the observed state of EgressOnlyInternetGateway. +type EgressOnlyInternetGatewayStatus struct { + v1.ResourceStatus `json:",inline"` + AtProvider EgressOnlyInternetGatewayObservation `json:"atProvider,omitempty"` +} + +// +kubebuilder:object:root=true + +// EgressOnlyInternetGateway is the Schema for the EgressOnlyInternetGateways API +// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" +// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" +// +kubebuilder:printcolumn:name="EXTERNAL-NAME",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name" +// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,awsjet} +type EgressOnlyInternetGateway struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec EgressOnlyInternetGatewaySpec `json:"spec"` + Status EgressOnlyInternetGatewayStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// EgressOnlyInternetGatewayList contains a list of EgressOnlyInternetGateways +type EgressOnlyInternetGatewayList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []EgressOnlyInternetGateway `json:"items"` +} + +// Repository type metadata. +var ( + EgressOnlyInternetGateway_Kind = "EgressOnlyInternetGateway" + EgressOnlyInternetGateway_GroupKind = schema.GroupKind{Group: CRDGroup, Kind: EgressOnlyInternetGateway_Kind}.String() + EgressOnlyInternetGateway_KindAPIVersion = EgressOnlyInternetGateway_Kind + "." + CRDGroupVersion.String() + EgressOnlyInternetGateway_GroupVersionKind = CRDGroupVersion.WithKind(EgressOnlyInternetGateway_Kind) +) + +func init() { + SchemeBuilder.Register(&EgressOnlyInternetGateway{}, &EgressOnlyInternetGatewayList{}) +} diff --git a/apis/ec2/v1alpha2/zz_generated.deepcopy.go b/apis/ec2/v1alpha2/zz_generated.deepcopy.go index 3e480000a..d09a93776 100644 --- a/apis/ec2/v1alpha2/zz_generated.deepcopy.go +++ b/apis/ec2/v1alpha2/zz_generated.deepcopy.go @@ -1101,6 +1101,184 @@ func (in *EgressObservation) DeepCopy() *EgressObservation { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EgressOnlyInternetGateway) DeepCopyInto(out *EgressOnlyInternetGateway) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EgressOnlyInternetGateway. +func (in *EgressOnlyInternetGateway) DeepCopy() *EgressOnlyInternetGateway { + if in == nil { + return nil + } + out := new(EgressOnlyInternetGateway) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *EgressOnlyInternetGateway) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EgressOnlyInternetGatewayList) DeepCopyInto(out *EgressOnlyInternetGatewayList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]EgressOnlyInternetGateway, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EgressOnlyInternetGatewayList. +func (in *EgressOnlyInternetGatewayList) DeepCopy() *EgressOnlyInternetGatewayList { + if in == nil { + return nil + } + out := new(EgressOnlyInternetGatewayList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *EgressOnlyInternetGatewayList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EgressOnlyInternetGatewayObservation) DeepCopyInto(out *EgressOnlyInternetGatewayObservation) { + *out = *in + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } + if in.TagsAll != nil { + in, out := &in.TagsAll, &out.TagsAll + *out = make(map[string]*string, len(*in)) + for key, val := range *in { + var outVal *string + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = new(string) + **out = **in + } + (*out)[key] = outVal + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EgressOnlyInternetGatewayObservation. +func (in *EgressOnlyInternetGatewayObservation) DeepCopy() *EgressOnlyInternetGatewayObservation { + if in == nil { + return nil + } + out := new(EgressOnlyInternetGatewayObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EgressOnlyInternetGatewayParameters) DeepCopyInto(out *EgressOnlyInternetGatewayParameters) { + *out = *in + if in.Region != nil { + in, out := &in.Region, &out.Region + *out = new(string) + **out = **in + } + if in.Tags != nil { + in, out := &in.Tags, &out.Tags + *out = make(map[string]*string, len(*in)) + for key, val := range *in { + var outVal *string + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = new(string) + **out = **in + } + (*out)[key] = outVal + } + } + if in.VPCID != nil { + in, out := &in.VPCID, &out.VPCID + *out = new(string) + **out = **in + } + if in.VpcIdRef != nil { + in, out := &in.VpcIdRef, &out.VpcIdRef + *out = new(v1.Reference) + **out = **in + } + if in.VpcIdSelector != nil { + in, out := &in.VpcIdSelector, &out.VpcIdSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EgressOnlyInternetGatewayParameters. +func (in *EgressOnlyInternetGatewayParameters) DeepCopy() *EgressOnlyInternetGatewayParameters { + if in == nil { + return nil + } + out := new(EgressOnlyInternetGatewayParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EgressOnlyInternetGatewaySpec) DeepCopyInto(out *EgressOnlyInternetGatewaySpec) { + *out = *in + in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) + in.ForProvider.DeepCopyInto(&out.ForProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EgressOnlyInternetGatewaySpec. +func (in *EgressOnlyInternetGatewaySpec) DeepCopy() *EgressOnlyInternetGatewaySpec { + if in == nil { + return nil + } + out := new(EgressOnlyInternetGatewaySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EgressOnlyInternetGatewayStatus) DeepCopyInto(out *EgressOnlyInternetGatewayStatus) { + *out = *in + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) + in.AtProvider.DeepCopyInto(&out.AtProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EgressOnlyInternetGatewayStatus. +func (in *EgressOnlyInternetGatewayStatus) DeepCopy() *EgressOnlyInternetGatewayStatus { + if in == nil { + return nil + } + out := new(EgressOnlyInternetGatewayStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EgressParameters) DeepCopyInto(out *EgressParameters) { *out = *in @@ -4320,6 +4498,16 @@ func (in *RouteTableRouteParameters) DeepCopyInto(out *RouteTableRouteParameters *out = new(string) **out = **in } + if in.EgressOnlyGatewayIDRef != nil { + in, out := &in.EgressOnlyGatewayIDRef, &out.EgressOnlyGatewayIDRef + *out = new(v1.Reference) + **out = **in + } + if in.EgressOnlyGatewayIDSelector != nil { + in, out := &in.EgressOnlyGatewayIDSelector, &out.EgressOnlyGatewayIDSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.GatewayID != nil { in, out := &in.GatewayID, &out.GatewayID *out = new(string) diff --git a/apis/ec2/v1alpha2/zz_generated.managed.go b/apis/ec2/v1alpha2/zz_generated.managed.go index 8899b76b8..7b627f0b1 100644 --- a/apis/ec2/v1alpha2/zz_generated.managed.go +++ b/apis/ec2/v1alpha2/zz_generated.managed.go @@ -151,6 +151,72 @@ func (mg *EIP) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { mg.Spec.WriteConnectionSecretToReference = r } +// GetCondition of this EgressOnlyInternetGateway. +func (mg *EgressOnlyInternetGateway) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this EgressOnlyInternetGateway. +func (mg *EgressOnlyInternetGateway) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetProviderConfigReference of this EgressOnlyInternetGateway. +func (mg *EgressOnlyInternetGateway) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +/* +GetProviderReference of this EgressOnlyInternetGateway. +Deprecated: Use GetProviderConfigReference. +*/ +func (mg *EgressOnlyInternetGateway) GetProviderReference() *xpv1.Reference { + return mg.Spec.ProviderReference +} + +// GetPublishConnectionDetailsTo of this EgressOnlyInternetGateway. +func (mg *EgressOnlyInternetGateway) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { + return mg.Spec.PublishConnectionDetailsTo +} + +// GetWriteConnectionSecretToReference of this EgressOnlyInternetGateway. +func (mg *EgressOnlyInternetGateway) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this EgressOnlyInternetGateway. +func (mg *EgressOnlyInternetGateway) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this EgressOnlyInternetGateway. +func (mg *EgressOnlyInternetGateway) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetProviderConfigReference of this EgressOnlyInternetGateway. +func (mg *EgressOnlyInternetGateway) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +/* +SetProviderReference of this EgressOnlyInternetGateway. +Deprecated: Use SetProviderConfigReference. +*/ +func (mg *EgressOnlyInternetGateway) SetProviderReference(r *xpv1.Reference) { + mg.Spec.ProviderReference = r +} + +// SetPublishConnectionDetailsTo of this EgressOnlyInternetGateway. +func (mg *EgressOnlyInternetGateway) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { + mg.Spec.PublishConnectionDetailsTo = r +} + +// SetWriteConnectionSecretToReference of this EgressOnlyInternetGateway. +func (mg *EgressOnlyInternetGateway) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} + // GetCondition of this Instance. func (mg *Instance) GetCondition(ct xpv1.ConditionType) xpv1.Condition { return mg.Status.GetCondition(ct) diff --git a/apis/ec2/v1alpha2/zz_generated.managedlist.go b/apis/ec2/v1alpha2/zz_generated.managedlist.go index 7014bd8e2..40ff375b7 100644 --- a/apis/ec2/v1alpha2/zz_generated.managedlist.go +++ b/apis/ec2/v1alpha2/zz_generated.managedlist.go @@ -37,6 +37,15 @@ func (l *EIPList) GetItems() []resource.Managed { return items } +// GetItems of this EgressOnlyInternetGatewayList. +func (l *EgressOnlyInternetGatewayList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} + // GetItems of this InstanceList. func (l *InstanceList) GetItems() []resource.Managed { items := make([]resource.Managed, len(l.Items)) diff --git a/apis/ec2/v1alpha2/zz_generated.resolvers.go b/apis/ec2/v1alpha2/zz_generated.resolvers.go index 9e3271e42..fbe978c03 100644 --- a/apis/ec2/v1alpha2/zz_generated.resolvers.go +++ b/apis/ec2/v1alpha2/zz_generated.resolvers.go @@ -95,6 +95,32 @@ func (mg *EIP) ResolveReferences(ctx context.Context, c client.Reader) error { return nil } +// ResolveReferences of this EgressOnlyInternetGateway. +func (mg *EgressOnlyInternetGateway) ResolveReferences(ctx context.Context, c client.Reader) error { + r := reference.NewAPIResolver(c, mg) + + var rsp reference.ResolutionResponse + var err error + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.VPCID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.VpcIdRef, + Selector: mg.Spec.ForProvider.VpcIdSelector, + To: reference.To{ + List: &VPCList{}, + Managed: &VPC{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.VPCID") + } + mg.Spec.ForProvider.VPCID = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.VpcIdRef = rsp.ResolvedReference + + return nil +} + // ResolveReferences of this Instance. func (mg *Instance) ResolveReferences(ctx context.Context, c client.Reader) error { r := reference.NewAPIResolver(c, mg) @@ -577,6 +603,24 @@ func (mg *RouteTable) ResolveReferences(ctx context.Context, c client.Reader) er var rsp reference.ResolutionResponse var err error + for i3 := 0; i3 < len(mg.Spec.ForProvider.Route); i3++ { + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Route[i3].EgressOnlyGatewayID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.Route[i3].EgressOnlyGatewayIDRef, + Selector: mg.Spec.ForProvider.Route[i3].EgressOnlyGatewayIDSelector, + To: reference.To{ + List: &EgressOnlyInternetGatewayList{}, + Managed: &EgressOnlyInternetGateway{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.Route[i3].EgressOnlyGatewayID") + } + mg.Spec.ForProvider.Route[i3].EgressOnlyGatewayID = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.Route[i3].EgressOnlyGatewayIDRef = rsp.ResolvedReference + + } for i3 := 0; i3 < len(mg.Spec.ForProvider.Route); i3++ { rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Route[i3].InstanceID), diff --git a/apis/ec2/v1alpha2/zz_generated_terraformed.go b/apis/ec2/v1alpha2/zz_generated_terraformed.go index 081b6ff98..77c0b1af1 100755 --- a/apis/ec2/v1alpha2/zz_generated_terraformed.go +++ b/apis/ec2/v1alpha2/zz_generated_terraformed.go @@ -617,6 +617,80 @@ func (tr *TransitGatewayVPCAttachmentAccepter) GetTerraformSchemaVersion() int { return 0 } +// GetTerraformResourceType returns Terraform resource type for this EgressOnlyInternetGateway +func (mg *EgressOnlyInternetGateway) GetTerraformResourceType() string { + return "aws_egress_only_internet_gateway" +} + +// GetConnectionDetailsMapping for this EgressOnlyInternetGateway +func (tr *EgressOnlyInternetGateway) GetConnectionDetailsMapping() map[string]string { + return nil +} + +// GetObservation of this EgressOnlyInternetGateway +func (tr *EgressOnlyInternetGateway) GetObservation() (map[string]interface{}, error) { + o, err := json.TFParser.Marshal(tr.Status.AtProvider) + if err != nil { + return nil, err + } + base := map[string]interface{}{} + return base, json.TFParser.Unmarshal(o, &base) +} + +// SetObservation for this EgressOnlyInternetGateway +func (tr *EgressOnlyInternetGateway) SetObservation(obs map[string]interface{}) error { + p, err := json.TFParser.Marshal(obs) + if err != nil { + return err + } + return json.TFParser.Unmarshal(p, &tr.Status.AtProvider) +} + +// GetID returns ID of underlying Terraform resource of this EgressOnlyInternetGateway +func (tr *EgressOnlyInternetGateway) GetID() string { + if tr.Status.AtProvider.ID == nil { + return "" + } + return *tr.Status.AtProvider.ID +} + +// GetParameters of this EgressOnlyInternetGateway +func (tr *EgressOnlyInternetGateway) GetParameters() (map[string]interface{}, error) { + p, err := json.TFParser.Marshal(tr.Spec.ForProvider) + if err != nil { + return nil, err + } + base := map[string]interface{}{} + return base, json.TFParser.Unmarshal(p, &base) +} + +// SetParameters for this EgressOnlyInternetGateway +func (tr *EgressOnlyInternetGateway) SetParameters(params map[string]interface{}) error { + p, err := json.TFParser.Marshal(params) + if err != nil { + return err + } + return json.TFParser.Unmarshal(p, &tr.Spec.ForProvider) +} + +// LateInitialize this EgressOnlyInternetGateway using its observed tfState. +// returns True if there are any spec changes for the resource. +func (tr *EgressOnlyInternetGateway) LateInitialize(attrs []byte) (bool, error) { + params := &EgressOnlyInternetGatewayParameters{} + if err := json.TFParser.Unmarshal(attrs, params); err != nil { + return false, errors.Wrap(err, "failed to unmarshal Terraform state parameters for late-initialization") + } + opts := []resource.GenericLateInitializerOption{resource.WithZeroValueJSONOmitEmptyFilter(resource.CNameWildcard)} + + li := resource.NewGenericLateInitializer(opts...) + return li.LateInitialize(&tr.Spec.ForProvider, params) +} + +// GetTerraformSchemaVersion returns the associated Terraform schema version +func (tr *EgressOnlyInternetGateway) GetTerraformSchemaVersion() int { + return 0 +} + // GetTerraformResourceType returns Terraform resource type for this EIP func (mg *EIP) GetTerraformResourceType() string { return "aws_eip" diff --git a/apis/ec2/v1alpha2/zz_routetable_types.go b/apis/ec2/v1alpha2/zz_routetable_types.go index aef899b5c..40568a96c 100755 --- a/apis/ec2/v1alpha2/zz_routetable_types.go +++ b/apis/ec2/v1alpha2/zz_routetable_types.go @@ -78,9 +78,16 @@ type RouteTableRouteParameters struct { // +kubebuilder:validation:Optional DestinationPrefixListID *string `json:"destinationPrefixListId,omitempty" tf:"destination_prefix_list_id"` + // +crossplane:generate:reference:type=EgressOnlyInternetGateway // +kubebuilder:validation:Optional EgressOnlyGatewayID *string `json:"egressOnlyGatewayId,omitempty" tf:"egress_only_gateway_id"` + // +kubebuilder:validation:Optional + EgressOnlyGatewayIDRef *v1.Reference `json:"egressOnlyGatewayIdRef,omitempty" tf:"-"` + + // +kubebuilder:validation:Optional + EgressOnlyGatewayIDSelector *v1.Selector `json:"egressOnlyGatewayIdSelector,omitempty" tf:"-"` + // +kubebuilder:validation:Optional GatewayID *string `json:"gatewayId,omitempty" tf:"gateway_id"` diff --git a/config/ec2/config.go b/config/ec2/config.go index db108f82c..7bda4f729 100644 --- a/config/ec2/config.go +++ b/config/ec2/config.go @@ -315,6 +315,9 @@ func Configure(p *config.Provider) { r.References["route.instance_id"] = config.Reference{ Type: "Instance", } + r.References["route.egress_only_gateway_id"] = config.Reference{ + Type: "EgressOnlyInternetGateway", + } }) p.AddResourceConfigurator("aws_route_table_association", func(r *config.Resource) { @@ -351,4 +354,9 @@ func Configure(p *config.Provider) { r.Version = common.VersionV1Alpha2 r.ExternalName = config.IdentifierFromProvider }) + + p.AddResourceConfigurator("aws_egress_only_internet_gateway", func(r *config.Resource) { + r.Version = common.VersionV1Alpha2 + r.ExternalName = config.IdentifierFromProvider + }) } diff --git a/config/provider.go b/config/provider.go index cabf3d688..e33d8b149 100644 --- a/config/provider.go +++ b/config/provider.go @@ -110,6 +110,7 @@ var IncludedResources = []string{ "aws_vpc_peering_connection$", "aws_route_table_association$", "aws_internet_gateway$", + "aws_egress_only_internet_gateway$", // IAM "aws_iam_access_key$", diff --git a/internal/controller/ec2/egressonlyinternetgateway/zz_controller.go b/internal/controller/ec2/egressonlyinternetgateway/zz_controller.go new file mode 100755 index 000000000..4b8173960 --- /dev/null +++ b/internal/controller/ec2/egressonlyinternetgateway/zz_controller.go @@ -0,0 +1,63 @@ +/* +Copyright 2021 The Crossplane Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by terrajet. DO NOT EDIT. + +package egressonlyinternetgateway + +import ( + "time" + + "github.com/crossplane/crossplane-runtime/pkg/connection" + "github.com/crossplane/crossplane-runtime/pkg/event" + "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + tjcontroller "github.com/crossplane/terrajet/pkg/controller" + "github.com/crossplane/terrajet/pkg/terraform" + ctrl "sigs.k8s.io/controller-runtime" + + v1alpha2 "github.com/crossplane-contrib/provider-jet-aws/apis/ec2/v1alpha2" +) + +// Setup adds a controller that reconciles EgressOnlyInternetGateway managed resources. +func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { + name := managed.ControllerName(v1alpha2.EgressOnlyInternetGateway_GroupVersionKind.String()) + var initializers managed.InitializerChain + for _, i := range o.Provider.Resources["aws_egress_only_internet_gateway"].InitializerFns { + initializers = append(initializers, i(mgr.GetClient())) + } + cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} + if o.SecretStoreConfigGVK != nil { + cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), *o.SecretStoreConfigGVK)) + } + r := managed.NewReconciler(mgr, + xpresource.ManagedKind(v1alpha2.EgressOnlyInternetGateway_GroupVersionKind), + managed.WithExternalConnecter(tjcontroller.NewConnector(mgr.GetClient(), o.WorkspaceStore, o.SetupFn, o.Provider.Resources["aws_egress_only_internet_gateway"])), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), + managed.WithFinalizer(terraform.NewWorkspaceFinalizer(o.WorkspaceStore, xpresource.NewAPIFinalizer(mgr.GetClient(), managed.FinalizerName))), + managed.WithTimeout(3*time.Minute), + managed.WithInitializers(initializers), + managed.WithConnectionPublishers(cps...), + ) + + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + For(&v1alpha2.EgressOnlyInternetGateway{}). + Complete(ratelimiter.NewReconciler(name, r, o.GlobalRateLimiter)) +} diff --git a/internal/controller/zz_setup.go b/internal/controller/zz_setup.go index bff9d75d7..cedbcaf45 100755 --- a/internal/controller/zz_setup.go +++ b/internal/controller/zz_setup.go @@ -24,6 +24,7 @@ import ( attachment "github.com/crossplane-contrib/provider-jet-aws/internal/controller/autoscaling/attachment" autoscalinggroup "github.com/crossplane-contrib/provider-jet-aws/internal/controller/autoscaling/autoscalinggroup" ebsvolume "github.com/crossplane-contrib/provider-jet-aws/internal/controller/ec2/ebsvolume" + egressonlyinternetgateway "github.com/crossplane-contrib/provider-jet-aws/internal/controller/ec2/egressonlyinternetgateway" eip "github.com/crossplane-contrib/provider-jet-aws/internal/controller/ec2/eip" instance "github.com/crossplane-contrib/provider-jet-aws/internal/controller/ec2/instance" internetgateway "github.com/crossplane-contrib/provider-jet-aws/internal/controller/ec2/internetgateway" @@ -127,6 +128,7 @@ func Setup(mgr ctrl.Manager, o controller.Options) error { attachment.Setup, autoscalinggroup.Setup, ebsvolume.Setup, + egressonlyinternetgateway.Setup, eip.Setup, instance.Setup, internetgateway.Setup, diff --git a/package/crds/ec2.aws.jet.crossplane.io_egressonlyinternetgateways.yaml b/package/crds/ec2.aws.jet.crossplane.io_egressonlyinternetgateways.yaml new file mode 100644 index 000000000..6251aaf29 --- /dev/null +++ b/package/crds/ec2.aws.jet.crossplane.io_egressonlyinternetgateways.yaml @@ -0,0 +1,259 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.8.0 + creationTimestamp: null + name: egressonlyinternetgateways.ec2.aws.jet.crossplane.io +spec: + group: ec2.aws.jet.crossplane.io + names: + categories: + - crossplane + - managed + - awsjet + kind: EgressOnlyInternetGateway + listKind: EgressOnlyInternetGatewayList + plural: egressonlyinternetgateways + singular: egressonlyinternetgateway + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + - jsonPath: .metadata.annotations.crossplane\.io/external-name + name: EXTERNAL-NAME + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha2 + schema: + openAPIV3Schema: + description: EgressOnlyInternetGateway is the Schema for the EgressOnlyInternetGateways + API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: EgressOnlyInternetGatewaySpec defines the desired state of + EgressOnlyInternetGateway + properties: + deletionPolicy: + default: Delete + description: DeletionPolicy specifies what will happen to the underlying + external when this managed resource is deleted - either "Delete" + or "Orphan" the external resource. + enum: + - Orphan + - Delete + type: string + forProvider: + properties: + region: + description: Region is the region you'd like your resource to + be created in. + type: string + tags: + additionalProperties: + type: string + type: object + vpcId: + type: string + vpcIdRef: + description: A Reference to a named object. + properties: + name: + description: Name of the referenced object. + type: string + required: + - name + type: object + vpcIdSelector: + description: A Selector selects an object. + properties: + matchControllerRef: + description: MatchControllerRef ensures an object with the + same controller reference as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + type: object + required: + - region + type: object + providerConfigRef: + default: + name: default + description: ProviderConfigReference specifies how the provider that + will be used to create, observe, update, and delete this managed + resource should be configured. + properties: + name: + description: Name of the referenced object. + type: string + required: + - name + type: object + providerRef: + description: 'ProviderReference specifies the provider that will be + used to create, observe, update, and delete this managed resource. + Deprecated: Please use ProviderConfigReference, i.e. `providerConfigRef`' + properties: + name: + description: Name of the referenced object. + type: string + required: + - name + type: object + publishConnectionDetailsTo: + description: PublishConnectionDetailsTo specifies the connection secret + config which contains a name, metadata and a reference to secret + store config to which any connection details for this managed resource + should be written. Connection details frequently include the endpoint, + username, and password required to connect to the managed resource. + properties: + configRef: + default: + name: default + description: SecretStoreConfigRef specifies which secret store + config should be used for this ConnectionSecret. + properties: + name: + description: Name of the referenced object. + type: string + required: + - name + type: object + metadata: + description: Metadata is the metadata for connection secret. + properties: + annotations: + additionalProperties: + type: string + description: Annotations are the annotations to be added to + connection secret. - For Kubernetes secrets, this will be + used as "metadata.annotations". - It is up to Secret Store + implementation for others store types. + type: object + labels: + additionalProperties: + type: string + description: Labels are the labels/tags to be added to connection + secret. - For Kubernetes secrets, this will be used as "metadata.labels". + - It is up to Secret Store implementation for others store + types. + type: object + type: + description: Type is the SecretType for the connection secret. + - Only valid for Kubernetes Secret Stores. + type: string + type: object + name: + description: Name is the name of the connection secret. + type: string + required: + - name + type: object + writeConnectionSecretToRef: + description: WriteConnectionSecretToReference specifies the namespace + and name of a Secret to which any connection details for this managed + resource should be written. Connection details frequently include + the endpoint, username, and password required to connect to the + managed resource. This field is planned to be replaced in a future + release in favor of PublishConnectionDetailsTo. Currently, both + could be set independently and connection details would be published + to both without affecting each other. + properties: + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - name + - namespace + type: object + required: + - forProvider + type: object + status: + description: EgressOnlyInternetGatewayStatus defines the observed state + of EgressOnlyInternetGateway. + properties: + atProvider: + properties: + id: + type: string + tagsAll: + additionalProperties: + type: string + type: object + type: object + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: LastTransitionTime is the last time this condition + transitioned from one status to another. + format: date-time + type: string + message: + description: A Message containing details about this condition's + last transition from one status to another, if any. + type: string + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: Type of this condition. At most one of each condition + type may apply to a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/package/crds/ec2.aws.jet.crossplane.io_routetables.yaml b/package/crds/ec2.aws.jet.crossplane.io_routetables.yaml index b27a76657..31848a338 100644 --- a/package/crds/ec2.aws.jet.crossplane.io_routetables.yaml +++ b/package/crds/ec2.aws.jet.crossplane.io_routetables.yaml @@ -82,6 +82,30 @@ spec: type: string egressOnlyGatewayId: type: string + egressOnlyGatewayIdRef: + description: A Reference to a named object. + properties: + name: + description: Name of the referenced object. + type: string + required: + - name + type: object + egressOnlyGatewayIdSelector: + description: A Selector selects an object. + properties: + matchControllerRef: + description: MatchControllerRef ensures an object with + the same controller reference as the selecting object + is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching + labels is selected. + type: object + type: object gatewayId: type: string instanceId: