diff --git a/upup/pkg/fi/cloudup/awstasks/autoscaling_group.go b/upup/pkg/fi/cloudup/awstasks/autoscaling_group.go index ed44344032..849b5e3f91 100644 --- a/upup/pkg/fi/cloudup/awstasks/autoscaling_group.go +++ b/upup/pkg/fi/cloudup/awstasks/autoscaling_group.go @@ -10,14 +10,8 @@ import ( "k8s.io/kube-deploy/upup/pkg/fi" "k8s.io/kube-deploy/upup/pkg/fi/cloudup/awsup" "strings" - "time" ) -func buildTimestampString() string { - now := time.Now() - return now.UTC().Format("20060102T150405Z") -} - // This one is a little weird because we can't update a launch configuration // So we have to create the launch configuration as part of the group //go:generate fitask -type=AutoscalingGroup @@ -157,7 +151,7 @@ func (e *AutoscalingGroup) buildTags(cloud fi.Cloud) map[string]string { func (_ *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *AutoscalingGroup) error { if a == nil { - launchConfigurationName := *e.Name + "-" + buildTimestampString() + launchConfigurationName := *e.Name + "-" + fi.BuildTimestampString() glog.V(2).Infof("Creating autoscaling LaunchConfiguration with Name:%q", launchConfigurationName) err := renderAutoscalingLaunchConfigurationAWS(t, launchConfigurationName, e) @@ -196,7 +190,7 @@ func (_ *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos } } else { if changes.UserData != nil { - launchConfigurationName := *e.Name + "-" + buildTimestampString() + launchConfigurationName := *e.Name + "-" + fi.BuildTimestampString() glog.V(2).Infof("Creating autoscaling LaunchConfiguration with Name:%q", launchConfigurationName) err := renderAutoscalingLaunchConfigurationAWS(t, launchConfigurationName, e) diff --git a/upup/pkg/fi/cloudup/awstasks/dhcp_options.go b/upup/pkg/fi/cloudup/awstasks/dhcp_options.go index 67e4254588..2aceb41b6a 100644 --- a/upup/pkg/fi/cloudup/awstasks/dhcp_options.go +++ b/upup/pkg/fi/cloudup/awstasks/dhcp_options.go @@ -19,6 +19,12 @@ type DHCPOptions struct { DomainNameServers *string } +var _ fi.CompareWithID = &DHCPOptions{} + +func (e *DHCPOptions) CompareWithID() *string { + return e.ID +} + func (e *DHCPOptions) Find(c *fi.Context) (*DHCPOptions, error) { cloud := c.Cloud.(*awsup.AWSCloud) diff --git a/upup/pkg/fi/cloudup/awstasks/dns_name.go b/upup/pkg/fi/cloudup/awstasks/dns_name.go index f8e3810d1a..b8bd13ee43 100644 --- a/upup/pkg/fi/cloudup/awstasks/dns_name.go +++ b/upup/pkg/fi/cloudup/awstasks/dns_name.go @@ -41,12 +41,14 @@ func (e *DNSName) Find(c *fi.Context) (*DNSName, error) { err := cloud.Route53.ListResourceRecordSetsPages(request, func(p *route53.ListResourceRecordSetsOutput, lastPage bool) (shouldContinue bool) { for _, rr := range p.ResourceRecordSets { resourceType := aws.StringValue(rr.Type) + name := aws.StringValue(rr.Name) + + glog.V(4).Infof("Found DNS resource %q %q", resourceType, name) if findType != resourceType { continue } - name := aws.StringValue(rr.Name) name = strings.TrimSuffix(name, ".") if name == findName { @@ -92,6 +94,7 @@ func (s *DNSName) CheckChanges(a, e, changes *DNSName) error { func (_ *DNSName) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *DNSName) error { rrs := &route53.ResourceRecordSet{ Name: e.Name, + Type: aws.String(e.ResourceType), } if e.TargetLoadBalancer != nil { @@ -100,7 +103,6 @@ func (_ *DNSName) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *DNSName) error EvaluateTargetHealth: aws.Bool(false), HostedZoneId: e.TargetLoadBalancer.HostedZoneId, } - rrs.Type = aws.String("A") } change := &route53.Change{ diff --git a/upup/pkg/fi/cloudup/awstasks/dns_zone.go b/upup/pkg/fi/cloudup/awstasks/dns_zone.go index 291ac70c32..b561e77c34 100644 --- a/upup/pkg/fi/cloudup/awstasks/dns_zone.go +++ b/upup/pkg/fi/cloudup/awstasks/dns_zone.go @@ -17,6 +17,12 @@ type DNSZone struct { ID *string } +var _ fi.CompareWithID = &DNSZone{} + +func (e *DNSZone) CompareWithID() *string { + return e.Name +} + func (e *DNSZone) Find(c *fi.Context) (*DNSZone, error) { cloud := c.Cloud.(*awsup.AWSCloud) diff --git a/upup/pkg/fi/cloudup/awstasks/ebs_volume.go b/upup/pkg/fi/cloudup/awstasks/ebs_volume.go index aeaf6f735d..564ba3b463 100644 --- a/upup/pkg/fi/cloudup/awstasks/ebs_volume.go +++ b/upup/pkg/fi/cloudup/awstasks/ebs_volume.go @@ -11,14 +11,20 @@ import ( //go:generate fitask -type=EBSVolume type EBSVolume struct { + Name *string ID *string AvailabilityZone *string VolumeType *string SizeGB *int64 - Name *string Tags map[string]string } +var _ fi.CompareWithID = &EBSVolume{} + +func (e *EBSVolume) CompareWithID() *string { + return e.ID +} + type TaggableResource interface { FindResourceID(c fi.Cloud) (*string, error) } diff --git a/upup/pkg/fi/cloudup/awstasks/iam_instance_profile.go b/upup/pkg/fi/cloudup/awstasks/iam_instance_profile.go index 7c8b82123c..34b59f00fb 100644 --- a/upup/pkg/fi/cloudup/awstasks/iam_instance_profile.go +++ b/upup/pkg/fi/cloudup/awstasks/iam_instance_profile.go @@ -12,8 +12,14 @@ import ( //go:generate fitask -type=IAMInstanceProfile type IAMInstanceProfile struct { - ID *string Name *string + ID *string +} + +var _ fi.CompareWithID = &IAMInstanceProfile{} + +func (e *IAMInstanceProfile) CompareWithID() *string { + return e.Name } func (e *IAMInstanceProfile) Find(c *fi.Context) (*IAMInstanceProfile, error) { diff --git a/upup/pkg/fi/cloudup/awstasks/iam_role.go b/upup/pkg/fi/cloudup/awstasks/iam_role.go index 0690a6afe5..ba357b6743 100644 --- a/upup/pkg/fi/cloudup/awstasks/iam_role.go +++ b/upup/pkg/fi/cloudup/awstasks/iam_role.go @@ -22,6 +22,12 @@ type IAMRole struct { RolePolicyDocument *fi.ResourceHolder // "inline" IAM policy } +var _ fi.CompareWithID = &IAMRole{} + +func (e *IAMRole) CompareWithID() *string { + return e.ID +} + func (e *IAMRole) Find(c *fi.Context) (*IAMRole, error) { cloud := c.Cloud.(*awsup.AWSCloud) diff --git a/upup/pkg/fi/cloudup/awstasks/internet_gateway.go b/upup/pkg/fi/cloudup/awstasks/internet_gateway.go index a6ee4c4ffa..52de60cb78 100644 --- a/upup/pkg/fi/cloudup/awstasks/internet_gateway.go +++ b/upup/pkg/fi/cloudup/awstasks/internet_gateway.go @@ -15,6 +15,12 @@ type InternetGateway struct { ID *string } +var _ fi.CompareWithID = &InternetGateway{} + +func (e *InternetGateway) CompareWithID() *string { + return e.ID +} + func (e *InternetGateway) Find(c *fi.Context) (*InternetGateway, error) { cloud := c.Cloud.(*awsup.AWSCloud) diff --git a/upup/pkg/fi/cloudup/awstasks/route_table.go b/upup/pkg/fi/cloudup/awstasks/route_table.go index 193bae4b80..cfb68d4aa3 100644 --- a/upup/pkg/fi/cloudup/awstasks/route_table.go +++ b/upup/pkg/fi/cloudup/awstasks/route_table.go @@ -16,6 +16,12 @@ type RouteTable struct { VPC *VPC } +var _ fi.CompareWithID = &RouteTable{} + +func (e *RouteTable) CompareWithID() *string { + return e.ID +} + func (e *RouteTable) Find(c *fi.Context) (*RouteTable, error) { cloud := c.Cloud.(*awsup.AWSCloud) diff --git a/upup/pkg/fi/cloudup/awstasks/ssh_key.go b/upup/pkg/fi/cloudup/awstasks/ssh_key.go index 646d47e4d7..c59a39429f 100644 --- a/upup/pkg/fi/cloudup/awstasks/ssh_key.go +++ b/upup/pkg/fi/cloudup/awstasks/ssh_key.go @@ -27,11 +27,15 @@ type SSHKey struct { PublicKey *fi.ResourceHolder - ID *string - KeyFingerprint *string } +var _ fi.CompareWithID = &SSHKey{} + +func (e *SSHKey) CompareWithID() *string { + return e.Name +} + func (e *SSHKey) Find(c *fi.Context) (*SSHKey, error) { cloud := c.Cloud.(*awsup.AWSCloud) @@ -61,7 +65,6 @@ func (e *SSHKey) Find(c *fi.Context) (*SSHKey, error) { actual := &SSHKey{ Name: k.KeyName, - ID: k.KeyName, KeyFingerprint: k.KeyFingerprint, } diff --git a/upup/pkg/fi/timestamp.go b/upup/pkg/fi/timestamp.go new file mode 100644 index 0000000000..8e7d3e593e --- /dev/null +++ b/upup/pkg/fi/timestamp.go @@ -0,0 +1,8 @@ +package fi + +import "time" + +func BuildTimestampString() string { + now := time.Now() + return now.UTC().Format("20060102150405") +}