From 465472a9583d77b11fc9249eb6408e92f17a77a1 Mon Sep 17 00:00:00 2001 From: Christian Bianchi Date: Thu, 21 Mar 2024 16:01:50 +0100 Subject: [PATCH 01/13] wip --- azs-getter/go.mod | 25 ++++++ azs-getter/go.sum | 38 ++++++++ azs-getter/internal/awshelper/awshelper.go | 64 ++++++++++++++ azs-getter/main.go | 98 +++++++++++++++++++++ helm/cluster-aws/files/azs-in-region.yaml | 80 +++++++++++++++++ helm/cluster-aws/templates/_aws_cluster.tpl | 19 ++-- helm/cluster-aws/templates/_awsazs.tpl | 22 +++++ helm/cluster-aws/templates/_awsregion.tpl | 2 +- helm/cluster-aws/values.schema.json | 1 - helm/cluster-aws/values.yaml | 18 ++-- 10 files changed, 347 insertions(+), 20 deletions(-) create mode 100644 azs-getter/go.mod create mode 100644 azs-getter/go.sum create mode 100644 azs-getter/internal/awshelper/awshelper.go create mode 100644 azs-getter/main.go create mode 100644 helm/cluster-aws/files/azs-in-region.yaml diff --git a/azs-getter/go.mod b/azs-getter/go.mod new file mode 100644 index 00000000..4c618d91 --- /dev/null +++ b/azs-getter/go.mod @@ -0,0 +1,25 @@ +module github.com/giantswarm/azs-getter + +go 1.22.1 + +require ( + github.com/aws/aws-sdk-go-v2/config v1.27.8 + github.com/aws/aws-sdk-go-v2/service/ec2 v1.152.0 +) + +require ( + github.com/aws/aws-sdk-go-v2 v1.26.0 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.17.8 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.15.4 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.4 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.4 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.1 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.6 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.20.3 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.3 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.28.5 // indirect + github.com/aws/smithy-go v1.20.1 // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/azs-getter/go.sum b/azs-getter/go.sum new file mode 100644 index 00000000..97f89b26 --- /dev/null +++ b/azs-getter/go.sum @@ -0,0 +1,38 @@ +github.com/aws/aws-sdk-go-v2 v1.26.0 h1:/Ce4OCiM3EkpW7Y+xUnfAFpchU78K7/Ug01sZni9PgA= +github.com/aws/aws-sdk-go-v2 v1.26.0/go.mod h1:35hUlJVYd+M++iLI3ALmVwMOyRYMmRqUXpTtRGW+K9I= +github.com/aws/aws-sdk-go-v2/config v1.27.8 h1:0r8epOsiJ7YJz65MGcb8i91ehFp4kvvFe2qkq5oYeRI= +github.com/aws/aws-sdk-go-v2/config v1.27.8/go.mod h1:XsmYKxYNuIhLsFddpNds+j9H5XKzjWDdg/SZngiwFio= +github.com/aws/aws-sdk-go-v2/credentials v1.17.8 h1:WUdNLXbyNbU07V/WFrSOBXqZTDgmmMNMgUFzpYOKJhw= +github.com/aws/aws-sdk-go-v2/credentials v1.17.8/go.mod h1:iPZzLpaBIfhyvVS/XGD3JvR1GP3YdHTqpySKDlqkfs8= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.15.4 h1:S+L2QSKhUuShih3aq9P/mkzDBiOO5tTyVg+vXREfsfg= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.15.4/go.mod h1:nQ3how7DMnFMWiU1SpECohgC82fpn4cKZ875NDMmwtA= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.4 h1:0ScVK/4qZ8CIW0k8jOeFVsyS/sAiXpYxRBLolMkuLQM= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.4/go.mod h1:84KyjNZdHC6QZW08nfHI6yZgPd+qRgaWcYsyLUo3QY8= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.4 h1:sHmMWWX5E7guWEFQ9SVo6A3S4xpPrWnd77a6y4WM6PU= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.4/go.mod h1:WjpDrhWisWOIoS9n3nk67A3Ll1vfULJ9Kq6h29HTD48= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 h1:hT8rVHwugYE2lEfdFE0QWVo81lF7jMrYJVDWI+f+VxU= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0/go.mod h1:8tu/lYfQfFe6IGnaOdrpVgEL2IrrDOf6/m9RQum4NkY= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.152.0 h1:ltCQObuImVYmIrMX65ikB9W83MEun3Ry2Sk11ecZ8Xw= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.152.0/go.mod h1:TeZ9dVQzGaLG+SBIgdLIDbJ6WmfFvksLeG3EHGnNfZM= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.1 h1:EyBZibRTVAs6ECHZOw5/wlylS9OcTzwyjeQMudmREjE= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.1/go.mod h1:JKpmtYhhPs7D97NL/ltqz7yCkERFW5dOlHyVl66ZYF8= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.6 h1:b+E7zIUHMmcB4Dckjpkapoy47W6C9QBv/zoUP+Hn8Kc= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.6/go.mod h1:S2fNV0rxrP78NhPbCZeQgY8H9jdDMeGtwcfZIRxzBqU= +github.com/aws/aws-sdk-go-v2/service/sso v1.20.3 h1:mnbuWHOcM70/OFUlZZ5rcdfA8PflGXXiefU/O+1S3+8= +github.com/aws/aws-sdk-go-v2/service/sso v1.20.3/go.mod h1:5HFu51Elk+4oRBZVxmHrSds5jFXmFj8C3w7DVF2gnrs= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.3 h1:uLq0BKatTmDzWa/Nu4WO0M1AaQDaPpwTKAeByEc6WFM= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.3/go.mod h1:b+qdhjnxj8GSR6t5YfphOffeoQSQ1KmpoVVuBn+PWxs= +github.com/aws/aws-sdk-go-v2/service/sts v1.28.5 h1:J/PpTf/hllOjx8Xu9DMflff3FajfLxqM5+tepvVXmxg= +github.com/aws/aws-sdk-go-v2/service/sts v1.28.5/go.mod h1:0ih0Z83YDH/QeQ6Ori2yGE2XvWYv/Xm+cZc01LC6oK0= +github.com/aws/smithy-go v1.20.1 h1:4SZlSlMr36UEqC7XOyRVb27XMeZubNcBNN+9IgEPIQw= +github.com/aws/smithy-go v1.20.1/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/azs-getter/internal/awshelper/awshelper.go b/azs-getter/internal/awshelper/awshelper.go new file mode 100644 index 00000000..bbc306c1 --- /dev/null +++ b/azs-getter/internal/awshelper/awshelper.go @@ -0,0 +1,64 @@ +package awshelper + +import ( + "context" + "fmt" + "strings" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" +) + +type AwsHelper struct { + sdkConfig aws.Config +} + +func New(awsConfig aws.Config) (*AwsHelper, error) { + return &AwsHelper{ + sdkConfig: awsConfig, + }, nil +} + +func (a *AwsHelper) ListRegions(ctx context.Context) ([]string, error) { + ec2Client := ec2.NewFromConfig(a.sdkConfig) + regionsOutput, err := ec2Client.DescribeRegions(ctx, &ec2.DescribeRegionsInput{ + AllRegions: aws.Bool(false), + }) + + if err != nil { + fmt.Println("Couldn't get regions") + return nil, err + } + + ret := make([]string, 0) + for _, region := range regionsOutput.Regions { + ret = append(ret, *region.RegionName) + } + + return ret, nil +} + +func (a *AwsHelper) GetAzsForRegion(ctx context.Context, region string) ([]string, error) { + config := a.sdkConfig + config.Region = region + ec2Client := ec2.NewFromConfig(config) + + azsOutput, err := ec2Client.DescribeAvailabilityZones(ctx, &ec2.DescribeAvailabilityZonesInput{ + AllAvailabilityZones: aws.Bool(true), + Filters: []types.Filter{{Name: aws.String("zone-type"), Values: []string{"availability-zone"}}}, + }) + + if err != nil { + return nil, err + } + + // We just want the zone letter (such as "a") rather than the full zone name (such as "us-west-2a") + zoneNames := make([]string, 0) + for _, az := range azsOutput.AvailabilityZones { + clean, _ := strings.CutPrefix(*az.ZoneName, region) + zoneNames = append(zoneNames, clean) + } + + return zoneNames, nil +} diff --git a/azs-getter/main.go b/azs-getter/main.go new file mode 100644 index 00000000..5569d58e --- /dev/null +++ b/azs-getter/main.go @@ -0,0 +1,98 @@ +package main + +import ( + "context" + "fmt" + "os" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/config" + awscreds "github.com/aws/aws-sdk-go-v2/credentials" + "gopkg.in/yaml.v3" + + "github.com/giantswarm/azs-getter/internal/awshelper" +) + +type credentials struct { + accessKeyId string + secretAccessKey string + region string +} + +func main() { + ctx := context.TODO() + + creds := []credentials{ + { + // EUROPE + accessKeyId: os.Getenv("AWS_ACCESS_KEY_ID_EUROPE"), + secretAccessKey: os.Getenv("AWS_SECRET_ACCESS_KEY_EUROPE"), + region: "eu-west-1", + }, + { + // CHINA + accessKeyId: os.Getenv("AWS_ACCESS_KEY_ID_CHINA"), + secretAccessKey: os.Getenv("AWS_SECRET_ACCESS_KEY_CHINA"), + region: "cn-north-1", + }, + } + + data := map[string][]string{} + + for _, c := range creds { + sdkConfig, err := config.LoadDefaultConfig(ctx, config.WithCredentialsProvider(awscreds.NewStaticCredentialsProvider(c.accessKeyId, c.secretAccessKey, "")), config.WithRegion(c.region)) + if err != nil { + fmt.Println("Couldn't load default configuration. Have you set up your AWS account?") + fmt.Println(err) + return + } + + azsPerRegion, err := getAzsFromCredentials(ctx, sdkConfig) + if err != nil { + fmt.Println("Error getting azs") + fmt.Println(err) + return + } + + for r, azs := range azsPerRegion { + data[r] = azs + } + } + + b, err := yaml.Marshal(data) + if err != nil { + fmt.Println("error marshaling azs to yaml") + fmt.Println(err) + return + } + + fmt.Print(string(b)) +} + +func getAzsFromCredentials(ctx context.Context, sdkConfig aws.Config) (map[string][]string, error) { + helper, err := awshelper.New(sdkConfig) + if err != nil { + fmt.Println("Error initializing aws helper") + return nil, err + } + + regions, err := helper.ListRegions(ctx) + if err != nil { + fmt.Println("Error listing regions") + return nil, err + } + + ret := make(map[string][]string) + + for _, region := range regions { + azs, err := helper.GetAzsForRegion(ctx, region) + if err != nil { + fmt.Printf("Couldn't get azs for region %s", region) + return nil, err + } + + ret[region] = azs + } + + return ret, nil +} diff --git a/helm/cluster-aws/files/azs-in-region.yaml b/helm/cluster-aws/files/azs-in-region.yaml new file mode 100644 index 00000000..244558bc --- /dev/null +++ b/helm/cluster-aws/files/azs-in-region.yaml @@ -0,0 +1,80 @@ +ap-northeast-1: + - a + - c + - d +ap-northeast-2: + - a + - b + - c + - d +ap-northeast-3: + - a + - b + - c +ap-south-1: + - a + - b + - c +ap-southeast-1: + - a + - b + - c +ap-southeast-2: + - a + - b + - c +ca-central-1: + - a + - b + - d +cn-north-1: + - a + - b + - d +cn-northwest-1: + - a + - b + - c +eu-central-1: + - a + - b + - c +eu-north-1: + - a + - b + - c +eu-west-1: + - a + - b + - c +eu-west-2: + - a + - b + - c +eu-west-3: + - a + - b + - c +sa-east-1: + - a + - b + - c +us-east-1: + - a + - b + - c + - d + - e + - f +us-east-2: + - a + - b + - c +us-west-1: + - a + - b +us-west-2: + - a + - b + - c + - d diff --git a/helm/cluster-aws/templates/_aws_cluster.tpl b/helm/cluster-aws/templates/_aws_cluster.tpl index 641a046d..773d2306 100644 --- a/helm/cluster-aws/templates/_aws_cluster.tpl +++ b/helm/cluster-aws/templates/_aws_cluster.tpl @@ -2,6 +2,9 @@ {{- if and (regexMatch "\\.internal$" (required "global.connectivity.baseDomain is required" .Values.global.connectivity.baseDomain)) (eq (required "global.connectivity.dns.mode required" .Values.global.connectivity.dns.mode) "public") }} {{- fail "global.connectivity.dns.mode=public cannot be combined with a '*.internal' baseDomain since reserved-as-private TLDs are not propagated to public DNS servers and therefore crucial DNS records such as api. cannot be looked up" }} {{- end }} +{{- $region := include "aws-region" . }} +{{/* $azs is a list of availability zones that are available for the region. Used for defaulting. */}} +{{- $azs := include "azs-in-region" (dict "region" $region "Files" .Files ) | fromYamlArray -}} apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 kind: AWSCluster metadata: @@ -81,14 +84,18 @@ spec: {{- end }} {{- else }} {{- range $i, $cidr := $subnet.cidrBlocks -}} + {{- /* + Use customer-specified availability zone for this subnet, default to picking one of the available zones from $azs variable + We use the 'mod' function as an index because it might be that the number of subnets and the number of availability zones differ in a region + */}} + {{- $az := $cidr.availabilityZone | default (index $azs (mod $i (len $azs))) -}} + {{- if (eq (len $az) 1) -}} + {{- $az = printf "%s%s" (include "aws-region" $) $az -}} + {{- end -}} {{/* CAPA v2.3.0 defaults to using the `id` field as subnet name unless it's an unmanaged one (`id` starts with `subnet-`), so use CAPA's previous standard subnet naming scheme */}} - - id: "{{ include "resource.default.name" $ }}-subnet-{{ $subnet.isPublic | default false | ternary "public" "private" }}-{{ if eq (len $cidr.availabilityZone) 1 }}{{ include "aws-region" $ }}{{ end }}{{ $cidr.availabilityZone }}" + - id: "{{ include "resource.default.name" $ }}-subnet-{{ $subnet.isPublic | default false | ternary "public" "private" }}-{{ $az }}" cidrBlock: "{{ $cidr.cidr }}" - {{- if eq (len $cidr.availabilityZone) 1 }} - availabilityZone: "{{ include "aws-region" $ }}{{ $cidr.availabilityZone }}" - {{- else }} - availabilityZone: "{{ $cidr.availabilityZone }}" - {{- end }} + availabilityZone: "{{ $az }}" isPublic: {{ $subnet.isPublic | default false }} {{- if or $subnet.tags $cidr.tags }} tags: diff --git a/helm/cluster-aws/templates/_awsazs.tpl b/helm/cluster-aws/templates/_awsazs.tpl index 0bd6c483..4b8a19bd 100644 --- a/helm/cluster-aws/templates/_awsazs.tpl +++ b/helm/cluster-aws/templates/_awsazs.tpl @@ -15,3 +15,25 @@ If no availability zones are provided in the values we'll attempt to look it up {{- end }} {{- end }} {{- end }} + +{{- /* +This helper returns a yaml encoded list of availability zones for a region. +It looks up such zones in a file `files/azs-in-region.yaml`. +If the region is missing from the file, it defaults to 'a', 'b' and 'c'. +*/}} +{{- define "azs-in-region" -}} +{{- $region := required "'azs-in-region' function requires a dict with a 'region' key" .region }} +{{- $azsInRegion := .Files.Get "files/azs-in-region.yaml" | fromYaml }} +{{- $azs := list -}} +{{- if hasKey $azsInRegion $region -}} +{{- range (index $azsInRegion $region) -}} +{{- $azs = append $azs (printf "%s%s" $region .) -}} +{{- end -}} +{{- else -}} +{{- /* Use 'a', 'b', and 'c' as default if the region is not in the azs-in-region.yaml file */ -}} +{{- $azs = append $azs (printf "%sa" $region) -}} +{{- $azs = append $azs (printf "%sb" $region) -}} +{{- $azs = append $azs (printf "%sc" $region) -}} +{{- end -}} +{{- toYaml $azs }} +{{- end -}} diff --git a/helm/cluster-aws/templates/_awsregion.tpl b/helm/cluster-aws/templates/_awsregion.tpl index 56049b23..697c302e 100644 --- a/helm/cluster-aws/templates/_awsregion.tpl +++ b/helm/cluster-aws/templates/_awsregion.tpl @@ -12,5 +12,5 @@ If no region is provided in the values we'll attempt to look it up based on the {{- end }} {{- end }} {{- end }} -{{- $region }} +{{- required "Unable to default the region. Please set .global.providerSpecific.region" $region }} {{- end }} diff --git a/helm/cluster-aws/values.schema.json b/helm/cluster-aws/values.schema.json index cce7e80d..7825fe0a 100644 --- a/helm/cluster-aws/values.schema.json +++ b/helm/cluster-aws/values.schema.json @@ -718,7 +718,6 @@ "items": { "type": "object", "required": [ - "availabilityZone", "cidr" ], "properties": { diff --git a/helm/cluster-aws/values.yaml b/helm/cluster-aws/values.yaml index 76dc9341..de3a3eb3 100644 --- a/helm/cluster-aws/values.yaml +++ b/helm/cluster-aws/values.yaml @@ -182,20 +182,14 @@ global: proxy: {} subnets: - cidrBlocks: - - availabilityZone: a - cidr: 10.0.0.0/20 - - availabilityZone: b - cidr: 10.0.16.0/20 - - availabilityZone: c - cidr: 10.0.32.0/20 + - cidr: 10.0.0.0/20 + - cidr: 10.0.16.0/20 + - cidr: 10.0.32.0/20 isPublic: true - cidrBlocks: - - availabilityZone: a - cidr: 10.0.64.0/18 - - availabilityZone: b - cidr: 10.0.128.0/18 - - availabilityZone: c - cidr: 10.0.192.0/18 + - cidr: 10.0.64.0/18 + - cidr: 10.0.128.0/18 + - cidr: 10.0.192.0/18 isPublic: false topology: mode: None From 24a6a6c1fea763d11dd6808a53513fbde8f4a101 Mon Sep 17 00:00:00 2001 From: Christian Bianchi Date: Thu, 21 Mar 2024 16:03:11 +0100 Subject: [PATCH 02/13] Smart defaulting for AWS availability zones using actual AZs in the region of choice rather than hardcoded values. --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30dd543f..a7edbcb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Update Chart.lock with current version of dependencies. +### Added + +- Smart defaulting for AWS availability zones using actual AZs in the region of choice rather than hardcoded values. + ## [0.66.0] - 2024-03-21 ### Added From cd59c5e1dbcc744c9427b15fce3d91efd28ec862 Mon Sep 17 00:00:00 2001 From: Christian Bianchi Date: Thu, 21 Mar 2024 16:06:22 +0100 Subject: [PATCH 03/13] Smart defaulting for AWS availability zones using actual AZs in the region of choice rather than hardcoded values. --- helm/cluster-aws/values.schema.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/helm/cluster-aws/values.schema.json b/helm/cluster-aws/values.schema.json index 7825fe0a..404f2d25 100644 --- a/helm/cluster-aws/values.schema.json +++ b/helm/cluster-aws/values.schema.json @@ -777,15 +777,12 @@ { "cidrBlocks": [ { - "availabilityZone": "a", "cidr": "10.0.0.0/20" }, { - "availabilityZone": "b", "cidr": "10.0.16.0/20" }, { - "availabilityZone": "c", "cidr": "10.0.32.0/20" } ], @@ -794,15 +791,12 @@ { "cidrBlocks": [ { - "availabilityZone": "a", "cidr": "10.0.64.0/18" }, { - "availabilityZone": "b", "cidr": "10.0.128.0/18" }, { - "availabilityZone": "c", "cidr": "10.0.192.0/18" } ], From 4dcfffc8b2b0bedd526923be18049823fbc58a33 Mon Sep 17 00:00:00 2001 From: Christian Bianchi Date: Thu, 21 Mar 2024 16:09:08 +0100 Subject: [PATCH 04/13] Smart defaulting for AWS availability zones using actual AZs in the region of choice rather than hardcoded values. --- helm/cluster-aws/README.md | 2 +- helm/cluster-aws/ci/ci-values.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/helm/cluster-aws/README.md b/helm/cluster-aws/README.md index 51674ce7..c2ad20b5 100644 --- a/helm/cluster-aws/README.md +++ b/helm/cluster-aws/README.md @@ -111,7 +111,7 @@ Properties within the `.global.connectivity` object | `global.connectivity.proxy.httpProxy` | **HTTP proxy** - To be passed to the HTTP_PROXY environment variable in all hosts.|**Type:** `string`
| | `global.connectivity.proxy.httpsProxy` | **HTTPS proxy** - To be passed to the HTTPS_PROXY environment variable in all hosts.|**Type:** `string`
| | `global.connectivity.proxy.noProxy` | **No proxy** - To be passed to the NO_PROXY environment variable in all hosts.|**Type:** `string`
| -| `global.connectivity.subnets` | **Subnets** - Subnets are created and tagged based on this definition.|**Type:** `array`
**Default:** `[{"cidrBlocks":[{"availabilityZone":"a","cidr":"10.0.0.0/20"},{"availabilityZone":"b","cidr":"10.0.16.0/20"},{"availabilityZone":"c","cidr":"10.0.32.0/20"}],"isPublic":true},{"cidrBlocks":[{"availabilityZone":"a","cidr":"10.0.64.0/18"},{"availabilityZone":"b","cidr":"10.0.128.0/18"},{"availabilityZone":"c","cidr":"10.0.192.0/18"}],"isPublic":false}]`| +| `global.connectivity.subnets` | **Subnets** - Subnets are created and tagged based on this definition.|**Type:** `array`
**Default:** `[{"cidrBlocks":[{"cidr":"10.0.0.0/20"},{"cidr":"10.0.16.0/20"},{"cidr":"10.0.32.0/20"}],"isPublic":true},{"cidrBlocks":[{"cidr":"10.0.64.0/18"},{"cidr":"10.0.128.0/18"},{"cidr":"10.0.192.0/18"}],"isPublic":false}]`| | `global.connectivity.subnets[*]` | **Subnet**|**Type:** `object`
| | `global.connectivity.subnets[*].cidrBlocks` | **Network**|**Type:** `array`
| | `global.connectivity.subnets[*].cidrBlocks[*]` |**None**|**Type:** `object`
| diff --git a/helm/cluster-aws/ci/ci-values.yaml b/helm/cluster-aws/ci/ci-values.yaml index af1f3f65..8b82d4a6 100644 --- a/helm/cluster-aws/ci/ci-values.yaml +++ b/helm/cluster-aws/ci/ci-values.yaml @@ -12,6 +12,7 @@ global: - r6i.xlarge - m5.xlarge providerSpecific: + region: "eu-west-1" awsAccountId: "1234567890" components: containerd: From 922908f1f0bb0944971b013d62afa9601682debf Mon Sep 17 00:00:00 2001 From: Christian Bianchi Date: Thu, 21 Mar 2024 16:11:00 +0100 Subject: [PATCH 05/13] Smart defaulting for AWS availability zones using actual AZs in the region of choice rather than hardcoded values. --- helm/cluster-aws/ci/test-mc-proxy-values.yaml | 2 ++ helm/cluster-aws/ci/test-network-topology-values.yaml | 2 ++ helm/cluster-aws/ci/test-spot-instances.yaml | 2 ++ helm/cluster-aws/ci/test-wc-minimal-values.yaml | 2 ++ 4 files changed, 8 insertions(+) diff --git a/helm/cluster-aws/ci/test-mc-proxy-values.yaml b/helm/cluster-aws/ci/test-mc-proxy-values.yaml index 8899f55b..21029f60 100644 --- a/helm/cluster-aws/ci/test-mc-proxy-values.yaml +++ b/helm/cluster-aws/ci/test-mc-proxy-values.yaml @@ -9,3 +9,5 @@ global: enabled: true httpProxy: http://proxy.mcproxy.example.com:4000 httpsProxy: http://proxy.mcproxy.example.com:4000 + providerSpecific: + region: "eu-west-1" diff --git a/helm/cluster-aws/ci/test-network-topology-values.yaml b/helm/cluster-aws/ci/test-network-topology-values.yaml index 71fabf48..a11b7313 100644 --- a/helm/cluster-aws/ci/test-network-topology-values.yaml +++ b/helm/cluster-aws/ci/test-network-topology-values.yaml @@ -12,3 +12,5 @@ global: vpcMode: private controlPlane: apiMode: private + providerSpecific: + region: "eu-west-1" diff --git a/helm/cluster-aws/ci/test-spot-instances.yaml b/helm/cluster-aws/ci/test-spot-instances.yaml index 766a477c..1044b676 100644 --- a/helm/cluster-aws/ci/test-spot-instances.yaml +++ b/helm/cluster-aws/ci/test-spot-instances.yaml @@ -12,3 +12,5 @@ global: spotInstances: enabled: true maxPrice: 1.2 + providerSpecific: + region: "eu-west-1" diff --git a/helm/cluster-aws/ci/test-wc-minimal-values.yaml b/helm/cluster-aws/ci/test-wc-minimal-values.yaml index 353a1744..c60b9296 100644 --- a/helm/cluster-aws/ci/test-wc-minimal-values.yaml +++ b/helm/cluster-aws/ci/test-wc-minimal-values.yaml @@ -5,3 +5,5 @@ global: servicePriority: lowest connectivity: baseDomain: example.com + providerSpecific: + region: "eu-west-1" From 58f5f0638c697add4f5c5de5de62aec5a48ea925 Mon Sep 17 00:00:00 2001 From: Christian Bianchi Date: Mon, 25 Mar 2024 09:17:41 +0100 Subject: [PATCH 06/13] automatically import azs --- .github/workflows/aws_azs.yaml | 92 ++++++++++++++++++++++++++++++++++ azs-getter/main.go | 18 ++++++- 2 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/aws_azs.yaml diff --git a/.github/workflows/aws_azs.yaml b/.github/workflows/aws_azs.yaml new file mode 100644 index 00000000..e8cd5cf6 --- /dev/null +++ b/.github/workflows/aws_azs.yaml @@ -0,0 +1,92 @@ +name: Update helm/cluster-aws/files/azs-in-region.yaml with new availability zones +on: + schedule: + - cron: '0 0 * * *' + +jobs: + import_new_regions_and_zones: + runs-on: ubuntu-20.04 + container: quay.io/giantswarm/devctl:6.13.0 + steps: + - name: Install dependencies + run: | + apk add --no-cache git + - name: Check out the code + uses: actions/checkout@v4 + with: + clean: false + - name: Calculate md5sum of azs-in-region.yaml before the script runs + run: | + md5sum helm/cluster-aws/files/azs-in-region.yaml > /tmp/before + - name: Run azs-getter to update azs-in-region.yaml + env: + AWS_ACCESS_KEY_ID_CHINA: "${{ secrets.AWS_ACCESS_KEY_ID_CHINA }}" + AWS_SECRET_ACCESS_KEY_CHINA: "${{ secrets.AWS_SECRET_ACCESS_KEY_CHINA }}" + AWS_ACCESS_KEY_ID_EUROPE: "${{ secrets.AWS_ACCESS_KEY_ID_EUROPE }}" + AWS_SECRET_ACCESS_KEY_EUROPE: "${{ secrets.AWS_SECRET_ACCESS_KEY_EUROPE }}" + run: | + cd azs-getter + go get + go run main.go --dest-file=../helm/cluster-aws/files/azs-in-region.yaml + - name: Check for changes + id: check_changes + run: | + md5sum helm/cluster-aws/files/azs-in-region.yaml > /tmp/after + + if diff /tmp/before /tmp/after + then + echo ::set-output name=needs_pr::true + fi + + - name: Add Changelog entry + env: + msg: "Update Availability Zones in helm/cluster-aws/files/azs-in-region.yaml" + if: steps.check_changes.outputs.needs_pr == 'true' + run: | + # Line number containing unreleased tag + unreleased="$(grep -En '^## \[Unreleased\]' CHANGELOG.md | cut -f1 -d:)" + + # Line number containing latest release + latest="$(grep -En '^## \[[0-9]+' CHANGELOG.md | head -n 1|cut -f1 -d:)" + + # Current changes + current="$(cat CHANGELOG.md | head -n $(($latest - 1))|tail -n $(($latest - $unreleased - 1)))" + + # look for "Added" section + added="$(echo "$current" | grep -En '^### Added'|cut -f1 -d:)" + + if [ "$added" == "" ] + then + added=2 + awk "NR==$(($unreleased + 1)){print \"\n## Added\n\"}7" CHANGELOG.md >changelog.tmp + mv changelog.tmp CHANGELOG.md + fi + + # Add new changelog entry + awk "NR==$(($unreleased + $added + 2)){print \"- ${msg}\"}7" CHANGELOG.md >changelog.tmp + mv changelog.tmp CHANGELOG.md + + - name: Prepare branch for PR + env: + remote_repo: "https://${{ github.actor }}:${{ secrets.TAYLORBOT_GITHUB_ACTION }}@github.com/${{ github.repository }}.git" + destination_branch_name: "automated-azs" + GITHUB_TOKEN: "${{ secrets.TAYLORBOT_GITHUB_ACTION }}" + base: "${{ github.ref }}" + if: steps.check_changes.outputs.needs_pr == 'true' + run: | + git config --global --add safe.directory "`pwd`" + git config --local user.email "dev@giantswarm.io" + git config --local user.name "taylorbot" + git add -A + git commit -m "Update Availability Zones in helm/cluster-aws/files/azs-in-region.yaml" + git push "${remote_repo}" HEAD:${destination_branch_name} --force + + - name: Create PR + uses: thomaseizinger/create-pull-request@1.3.1 + if: steps.check_changes.outputs.needs_pr == 'true' + with: + GITHUB_TOKEN: ${{ secrets.TAYLORBOT_GITHUB_ACTION }} + head: "automated-azs" + base: ${{ github.ref }} + title: "Update Availability Zones in helm/cluster-aws/files/azs-in-region.yaml" + diff --git a/azs-getter/main.go b/azs-getter/main.go index 5569d58e..e9c60937 100644 --- a/azs-getter/main.go +++ b/azs-getter/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "flag" "fmt" "os" @@ -22,6 +23,16 @@ type credentials struct { func main() { ctx := context.TODO() + var dest string + + flag.StringVar(&dest, "dest-file", "../helm/cluster-aws/files/azs-in-region.yaml", "Path of the yaml file where to write the new AZs") + flag.Parse() + + if dest == "" { + fmt.Println("No destination file provided, defaulting to stdout") + dest = "/dev/stdout" + } + creds := []credentials{ { // EUROPE @@ -66,7 +77,12 @@ func main() { return } - fmt.Print(string(b)) + err = os.WriteFile(dest, b, 0644) + if err != nil { + fmt.Println("error writing azs to file") + fmt.Println(err) + return + } } func getAzsFromCredentials(ctx context.Context, sdkConfig aws.Config) (map[string][]string, error) { From 15a99fb22c67248fdb75dd0afb0fab20ff7d3374 Mon Sep 17 00:00:00 2001 From: Christian Bianchi Date: Mon, 25 Mar 2024 09:26:03 +0100 Subject: [PATCH 07/13] automatically import azs --- .github/workflows/aws_azs.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/aws_azs.yaml b/.github/workflows/aws_azs.yaml index e8cd5cf6..02b05293 100644 --- a/.github/workflows/aws_azs.yaml +++ b/.github/workflows/aws_azs.yaml @@ -1,7 +1,10 @@ name: Update helm/cluster-aws/files/azs-in-region.yaml with new availability zones on: - schedule: - - cron: '0 0 * * *' + #schedule: + # - cron: '0 0 * * *' + push: + branches: + - smart-availability-zones jobs: import_new_regions_and_zones: From 6f0a10fbf32c57fd67d53276e6cc7edeedfbfc2b Mon Sep 17 00:00:00 2001 From: Christian Bianchi Date: Mon, 25 Mar 2024 09:31:12 +0100 Subject: [PATCH 08/13] automatically import azs --- .github/workflows/aws_azs.yaml | 16 ++++++++-------- azs-getter/main.go | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/aws_azs.yaml b/.github/workflows/aws_azs.yaml index 02b05293..677a3dbb 100644 --- a/.github/workflows/aws_azs.yaml +++ b/.github/workflows/aws_azs.yaml @@ -8,12 +8,9 @@ on: jobs: import_new_regions_and_zones: - runs-on: ubuntu-20.04 - container: quay.io/giantswarm/devctl:6.13.0 + runs-on: ubuntu-22.04 + container: quay.io/giantswarm/golang:1.22 steps: - - name: Install dependencies - run: | - apk add --no-cache git - name: Check out the code uses: actions/checkout@v4 with: @@ -21,6 +18,11 @@ jobs: - name: Calculate md5sum of azs-in-region.yaml before the script runs run: | md5sum helm/cluster-aws/files/azs-in-region.yaml > /tmp/before + - name: Build azs-getter + run: | + cd azs-getter + go get + go build -o ../azs-getter main.go - name: Run azs-getter to update azs-in-region.yaml env: AWS_ACCESS_KEY_ID_CHINA: "${{ secrets.AWS_ACCESS_KEY_ID_CHINA }}" @@ -28,9 +30,7 @@ jobs: AWS_ACCESS_KEY_ID_EUROPE: "${{ secrets.AWS_ACCESS_KEY_ID_EUROPE }}" AWS_SECRET_ACCESS_KEY_EUROPE: "${{ secrets.AWS_SECRET_ACCESS_KEY_EUROPE }}" run: | - cd azs-getter - go get - go run main.go --dest-file=../helm/cluster-aws/files/azs-in-region.yaml + ./azs-getter --dest-file=./helm/cluster-aws/files/azs-in-region.yaml - name: Check for changes id: check_changes run: | diff --git a/azs-getter/main.go b/azs-getter/main.go index e9c60937..dcaea82f 100644 --- a/azs-getter/main.go +++ b/azs-getter/main.go @@ -25,7 +25,7 @@ func main() { var dest string - flag.StringVar(&dest, "dest-file", "../helm/cluster-aws/files/azs-in-region.yaml", "Path of the yaml file where to write the new AZs") + flag.StringVar(&dest, "dest-file", "./helm/cluster-aws/files/azs-in-region.yaml", "Path of the yaml file where to write the new AZs") flag.Parse() if dest == "" { From 61ea1a523a6be8b7e686f697215c744af663e216 Mon Sep 17 00:00:00 2001 From: Christian Bianchi Date: Mon, 25 Mar 2024 09:32:10 +0100 Subject: [PATCH 09/13] automatically import azs --- .github/workflows/aws_azs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/aws_azs.yaml b/.github/workflows/aws_azs.yaml index 677a3dbb..653b85ad 100644 --- a/.github/workflows/aws_azs.yaml +++ b/.github/workflows/aws_azs.yaml @@ -9,7 +9,7 @@ on: jobs: import_new_regions_and_zones: runs-on: ubuntu-22.04 - container: quay.io/giantswarm/golang:1.22 + container: quay.io/giantswarm/golang:1.22.1 steps: - name: Check out the code uses: actions/checkout@v4 From 74d13e2a934448df4db5a44314278a375b2fb647 Mon Sep 17 00:00:00 2001 From: Christian Bianchi Date: Mon, 25 Mar 2024 09:34:22 +0100 Subject: [PATCH 10/13] automatically import azs --- .github/workflows/aws_azs.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/aws_azs.yaml b/.github/workflows/aws_azs.yaml index 653b85ad..47deeaa0 100644 --- a/.github/workflows/aws_azs.yaml +++ b/.github/workflows/aws_azs.yaml @@ -22,7 +22,7 @@ jobs: run: | cd azs-getter go get - go build -o ../azs-getter main.go + go build -o ../azs-getter-bin main.go - name: Run azs-getter to update azs-in-region.yaml env: AWS_ACCESS_KEY_ID_CHINA: "${{ secrets.AWS_ACCESS_KEY_ID_CHINA }}" @@ -30,7 +30,8 @@ jobs: AWS_ACCESS_KEY_ID_EUROPE: "${{ secrets.AWS_ACCESS_KEY_ID_EUROPE }}" AWS_SECRET_ACCESS_KEY_EUROPE: "${{ secrets.AWS_SECRET_ACCESS_KEY_EUROPE }}" run: | - ./azs-getter --dest-file=./helm/cluster-aws/files/azs-in-region.yaml + ./azs-getter-bin --dest-file=./helm/cluster-aws/files/azs-in-region.yaml + rm ./azs-getter-bin - name: Check for changes id: check_changes run: | From 42d4d7f72df9140c557c4cb7a5b5a287cbbfa0dc Mon Sep 17 00:00:00 2001 From: Christian Bianchi Date: Mon, 25 Mar 2024 09:40:00 +0100 Subject: [PATCH 11/13] automatically import azs --- .github/workflows/aws_azs.yaml | 12 ++++++------ azs-getter/go.mod | 6 +++--- azs-getter/go.sum | 5 +++++ azs-getter/main.go | 8 ++++---- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/aws_azs.yaml b/.github/workflows/aws_azs.yaml index 47deeaa0..659bd70e 100644 --- a/.github/workflows/aws_azs.yaml +++ b/.github/workflows/aws_azs.yaml @@ -56,18 +56,18 @@ jobs: # Current changes current="$(cat CHANGELOG.md | head -n $(($latest - 1))|tail -n $(($latest - $unreleased - 1)))" - # look for "Added" section - added="$(echo "$current" | grep -En '^### Added'|cut -f1 -d:)" + # look for "Changed" section + changed="$(echo "$current" | grep -En '^### Changed'|cut -f1 -d:)" - if [ "$added" == "" ] + if [ "$changed" == "" ] then - added=2 - awk "NR==$(($unreleased + 1)){print \"\n## Added\n\"}7" CHANGELOG.md >changelog.tmp + changed=2 + awk "NR==$(($unreleased + 1)){print \"\n## Changed\n\"}7" CHANGELOG.md >changelog.tmp mv changelog.tmp CHANGELOG.md fi # Add new changelog entry - awk "NR==$(($unreleased + $added + 2)){print \"- ${msg}\"}7" CHANGELOG.md >changelog.tmp + awk "NR==$(($unreleased + $changed + 2)){print \"- ${msg}\n\"}7" CHANGELOG.md >changelog.tmp mv changelog.tmp CHANGELOG.md - name: Prepare branch for PR diff --git a/azs-getter/go.mod b/azs-getter/go.mod index 4c618d91..4ed9b29d 100644 --- a/azs-getter/go.mod +++ b/azs-getter/go.mod @@ -3,13 +3,14 @@ module github.com/giantswarm/azs-getter go 1.22.1 require ( + github.com/aws/aws-sdk-go-v2 v1.26.0 github.com/aws/aws-sdk-go-v2/config v1.27.8 + github.com/aws/aws-sdk-go-v2/credentials v1.17.8 github.com/aws/aws-sdk-go-v2/service/ec2 v1.152.0 + gopkg.in/yaml.v3 v3.0.1 ) require ( - github.com/aws/aws-sdk-go-v2 v1.26.0 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.17.8 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.15.4 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.4 // indirect github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.4 // indirect @@ -21,5 +22,4 @@ require ( github.com/aws/aws-sdk-go-v2/service/sts v1.28.5 // indirect github.com/aws/smithy-go v1.20.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/azs-getter/go.sum b/azs-getter/go.sum index 97f89b26..736e2885 100644 --- a/azs-getter/go.sum +++ b/azs-getter/go.sum @@ -26,13 +26,18 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.28.5 h1:J/PpTf/hllOjx8Xu9DMflff3Fajf github.com/aws/aws-sdk-go-v2/service/sts v1.28.5/go.mod h1:0ih0Z83YDH/QeQ6Ori2yGE2XvWYv/Xm+cZc01LC6oK0= github.com/aws/smithy-go v1.20.1 h1:4SZlSlMr36UEqC7XOyRVb27XMeZubNcBNN+9IgEPIQw= github.com/aws/smithy-go v1.20.1/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/azs-getter/main.go b/azs-getter/main.go index dcaea82f..5a1998c3 100644 --- a/azs-getter/main.go +++ b/azs-getter/main.go @@ -55,14 +55,14 @@ func main() { if err != nil { fmt.Println("Couldn't load default configuration. Have you set up your AWS account?") fmt.Println(err) - return + os.Exit(1) } azsPerRegion, err := getAzsFromCredentials(ctx, sdkConfig) if err != nil { fmt.Println("Error getting azs") fmt.Println(err) - return + os.Exit(1) } for r, azs := range azsPerRegion { @@ -74,14 +74,14 @@ func main() { if err != nil { fmt.Println("error marshaling azs to yaml") fmt.Println(err) - return + os.Exit(1) } err = os.WriteFile(dest, b, 0644) if err != nil { fmt.Println("error writing azs to file") fmt.Println(err) - return + os.Exit(1) } } From 4b320761e7c8294d40cc4ec3848d7e278f881306 Mon Sep 17 00:00:00 2001 From: Christian Bianchi Date: Mon, 25 Mar 2024 10:12:22 +0100 Subject: [PATCH 12/13] automatically import azs --- azs-getter/main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azs-getter/main.go b/azs-getter/main.go index 5a1998c3..d3d1cb2c 100644 --- a/azs-getter/main.go +++ b/azs-getter/main.go @@ -62,7 +62,7 @@ func main() { if err != nil { fmt.Println("Error getting azs") fmt.Println(err) - os.Exit(1) + os.Exit(2) } for r, azs := range azsPerRegion { @@ -74,14 +74,14 @@ func main() { if err != nil { fmt.Println("error marshaling azs to yaml") fmt.Println(err) - os.Exit(1) + os.Exit(3) } err = os.WriteFile(dest, b, 0644) if err != nil { fmt.Println("error writing azs to file") fmt.Println(err) - os.Exit(1) + os.Exit(4) } } From 78aba395bd32f93cca6c16cfb1a01b973c8a42dc Mon Sep 17 00:00:00 2001 From: Christian Bianchi Date: Mon, 25 Mar 2024 10:17:22 +0100 Subject: [PATCH 13/13] automatically import azs --- .github/workflows/aws_azs.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/aws_azs.yaml b/.github/workflows/aws_azs.yaml index 659bd70e..ed9feda8 100644 --- a/.github/workflows/aws_azs.yaml +++ b/.github/workflows/aws_azs.yaml @@ -37,11 +37,7 @@ jobs: run: | md5sum helm/cluster-aws/files/azs-in-region.yaml > /tmp/after - if diff /tmp/before /tmp/after - then - echo ::set-output name=needs_pr::true - fi - + diff /tmp/before /tmp/after || echo ::set-output name=needs_pr::true - name: Add Changelog entry env: msg: "Update Availability Zones in helm/cluster-aws/files/azs-in-region.yaml"