Skip to content

Commit

Permalink
Merge pull request #75 from guessi/refresh-default-images
Browse files Browse the repository at this point in the history
Update outdated default image for AWS/GCP
  • Loading branch information
TP Honey authored Aug 30, 2022
2 parents a03cfb5 + 3cbdcd0 commit 79ea07e
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 42 deletions.
8 changes: 4 additions & 4 deletions config/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ func TestLoad(t *testing.T) {
"DRONE_GOOGLE_USERDATA": "#cloud-init",
"DRONE_GOOGLE_USERDATA_FILE": "/path/to/cloud/init.yml",
"DRONE_GOOGLE_READ_RATELIMIT": "20",
"DRONE_AMAZON_IMAGE": "ami-80ca47e6",
"DRONE_AMAZON_INSTANCE": "t2.medium",
"DRONE_AMAZON_IMAGE": "ami-07f84a50d2dec2fa4",
"DRONE_AMAZON_INSTANCE": "t3.medium",
"DRONE_AMAZON_PRIVATE_IP": "true",
"DRONE_AMAZON_RETRIES": "1",
"DRONE_AMAZON_REGION": "us-east-2",
Expand Down Expand Up @@ -257,8 +257,8 @@ var jsonConfig = []byte(`{
"UserDataFile": "/path/to/cloud/init.yml"
},
"Amazon": {
"Image": "ami-80ca47e6",
"Instance": "t2.medium",
"Image": "ami-07f84a50d2dec2fa4",
"Instance": "t3.medium",
"PrivateIP": true,
"Retries": 1,
"Region": "us-east-2",
Expand Down
8 changes: 4 additions & 4 deletions drivers/amazon/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import "testing"
func TestOptions(t *testing.T) {
p := New(
WithDeviceName("/dev/sda2"),
WithImage("ami-66506c1c"),
WithImage("ami-0aab355e1bfa1e72e"),
WithPrivateIP(true),
WithRegion("us-west-2"),
WithRetries(10),
WithSecurityGroup("sg-770eabe1"),
WithSize("t2.2xlarge"),
WithSize("t3.2xlarge"),
WithSSHKey("id_rsa"),
WithSubnet("subnet-0b32177f"),
WithTags(map[string]string{"foo": "bar", "baz": "qux"}),
Expand All @@ -25,13 +25,13 @@ func TestOptions(t *testing.T) {
if got, want := p.deviceName, "/dev/sda2"; got != want {
t.Errorf("Want device name %q, got %q", want, got)
}
if got, want := p.image, "ami-66506c1c"; got != want {
if got, want := p.image, "ami-0aab355e1bfa1e72e"; got != want {
t.Errorf("Want image %q, got %q", want, got)
}
if got, want := p.region, "us-west-2"; got != want {
t.Errorf("Want region %q, got %q", want, got)
}
if got, want := p.size, "t2.2xlarge"; got != want {
if got, want := p.size, "t3.2xlarge"; got != want {
t.Errorf("Want size %q, got %q", want, got)
}
if got, want := p.key, "id_rsa"; got != want {
Expand Down
2 changes: 1 addition & 1 deletion drivers/amazon/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func New(opts ...Option) autoscaler.Provider {
p.region = "us-east-1"
}
if p.size == "" {
p.size = "t2.medium"
p.size = "t3.medium"
}
if p.image == "" {
p.image = defaultImage(p.region)
Expand Down
58 changes: 40 additions & 18 deletions drivers/amazon/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,45 @@ func defaultImage(region string) string {
return images[region]
}

// static ami id list for Ubuntu Server 20.04 LTS
// source: https://cloud-images.ubuntu.com/locator/
// filters:
// - Cloud: Amazon AWS, Amazon GovCloud, Amazon AWS China
// - Version: 20.04
// - Instance Type: hvm-ssd
var images = map[string]string{
"ap-south-1": "ami-0189d76e",
"us-east-1": "ami-43a15f3e",
"ap-northeast-1": "ami-0d74386b",
"eu-west-1": "ami-f90a4880",
"ap-southeast-1": "ami-52d4802e",
"ca-central-1": "ami-ae55d2ca",
"us-west-1": "ami-925144f2",
"eu-central-1": "ami-7c412f13",
"sa-east-1": "ami-423d772e",
"cn-north-1": "ami-cc4499a1",
"cn-northwest-1": "ami-fd0e1a9f",
"us-gov-west-1": "ami-893fb4e8",
"ap-southeast-2": "ami-d38a4ab1",
"eu-west-2": "ami-f4f21593",
"ap-northeast-2": "ami-a414b9ca",
"us-west-2": "ami-4e79ed36",
"us-east-2": "ami-916f59f4",
"eu-west-3": "ami-0e55e373",
// AWS Regions: Ubuntu Server 20.04 LTS
// Upstream release version: 20220706
"af-south-1": "ami-0f5298ccab965edeb",
"ap-east-1": "ami-0dfad1f1f65cd083b",
"ap-northeast-1": "ami-0986c991cc80c6ad9",
"ap-northeast-2": "ami-0565d651769eb3de5",
"ap-northeast-3": "ami-0e6078093a109801c",
"ap-south-1": "ami-0325e3016099f9112",
"ap-southeast-1": "ami-0eaf04122a1ae7b3b",
"ap-southeast-2": "ami-048a2d001938101dd",
"ap-southeast-3": "ami-09915141a4f1dafdd",
"ca-central-1": "ami-04a579d2f00bb4001",
"eu-central-1": "ami-06cac34c3836ff90b",
"eu-north-1": "ami-0ede84a5f28ec932a",
"eu-south-1": "ami-0a39f417b8836bc59",
"eu-west-1": "ami-0141514361b6a3c1b",
"eu-west-2": "ami-014b642f603e350c3",
"eu-west-3": "ami-0d0b8d91779dec1e5",
"me-south-1": "ami-0c769d841005394ee",
"sa-east-1": "ami-088afbba294231fe0",
"us-east-1": "ami-0070c5311b7677678",
"us-east-2": "ami-07f84a50d2dec2fa4",
"us-west-1": "ami-040a251ee9d7d1a9b",
"us-west-2": "ami-0aab355e1bfa1e72e",

// AWS GovCloud (US): Ubuntu Server 20.04 LTS
// Upstream release version: 20220627.1
"us-gov-east-1": "ami-0d8ee446ec886f5cf",
"us-gov-west-1": "ami-0cbaf57cea1d72aec",

// AWS China: Ubuntu Server 20.04 LTS
// Upstream release version: 20210720
"cn-north-1": "ami-0741e7b8b4fb0001c",
"cn-northwest-1": "ami-0883e8062ff31f727",
}
6 changes: 3 additions & 3 deletions drivers/google/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestCreate(t *testing.T) {
if want, got := instance.Address, "1.2.3.4"; got != want {
t.Errorf("Want instance IP %q, got %q", want, got)
}
if want, got := instance.Image, "ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20170721"; got != want {
if want, got := instance.Image, "ubuntu-os-cloud/global/images/ubuntu-2004-focal-v20220712"; got != want {
t.Errorf("Want instance ID %q, got %q", want, got)
}
if want, got := instance.ID, "agent-807jvfwj"; got != want {
Expand Down Expand Up @@ -145,7 +145,7 @@ var insertInstanceMock = &compute.Instance{
AutoDelete: true,
DeviceName: "agent-807jvfwj",
InitializeParams: &compute.AttachedDiskInitializeParams{
SourceImage: "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20170721",
SourceImage: "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-2004-focal-v20220712",
DiskType: "projects/my-project/zones/us-central1-a/diskTypes/pd-standard",
DiskSizeGb: 50,
},
Expand Down Expand Up @@ -207,7 +207,7 @@ var insertInstanceMockB = &compute.Instance{
AutoDelete: true,
DeviceName: "agent-807jvfwj",
InitializeParams: &compute.AttachedDiskInitializeParams{
SourceImage: "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20170721",
SourceImage: "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-2004-focal-v20220712",
DiskType: "projects/my-project/zones/us-central1-b/diskTypes/pd-standard",
DiskSizeGb: 50,
},
Expand Down
2 changes: 1 addition & 1 deletion drivers/google/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func New(opts ...Option) (autoscaler.Provider, error) {
p.size = "n1-standard-1"
}
if p.image == "" {
p.image = "ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20170721"
p.image = "ubuntu-os-cloud/global/images/ubuntu-2004-focal-v20220712"
}
if p.network == "" {
p.network = "global/networks/default"
Expand Down
2 changes: 1 addition & 1 deletion drivers/google/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestDefaults(t *testing.T) {
if got, want := p.diskType, "pd-standard"; got != want {
t.Errorf("Want diskType %s, got %s", want, got)
}
if got, want := p.image, "ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20170721"; got != want {
if got, want := p.image, "ubuntu-os-cloud/global/images/ubuntu-2004-focal-v20220712"; got != want {
t.Errorf("Want image %q, got %q", want, got)
}
if got, want := p.network, "global/networks/default"; got != want {
Expand Down
20 changes: 10 additions & 10 deletions server/web/template/testdata/servers.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"Address": "54.194.252.215",
"Capacity": 2,
"Error": "",
"Image": "ami-cc4499a1",
"Size": "t2.medium",
"Image": "ami-0070c5311b7677678",
"Size": "t3.medium",
"Region": "us-east-1",
"Platform": "linux/amd64",
"Created": 1573575703,
Expand All @@ -25,8 +25,8 @@
"Address": "54.194.252.215",
"Capacity": 2,
"Error": "",
"Image": "ami-cc4499a1",
"Size": "t2.medium",
"Image": "ami-0070c5311b7677678",
"Size": "t3.medium",
"Region": "us-east-1",
"Platform": "linux/amd64",
"Created": 1573575703,
Expand All @@ -42,8 +42,8 @@
"Address": "54.194.252.215",
"Capacity": 2,
"Error": "",
"Image": "ami-cc4499a1",
"Size": "t2.medium",
"Image": "ami-0070c5311b7677678",
"Size": "t3.medium",
"Region": "us-east-1",
"Platform": "linux/amd64",
"Created": 1573575703,
Expand All @@ -59,8 +59,8 @@
"Address": "54.194.252.215",
"Capacity": 2,
"Error": "",
"Image": "ami-cc4499a1",
"Size": "t2.medium",
"Image": "ami-0070c5311b7677678",
"Size": "t3.medium",
"Region": "us-east-1",
"Platform": "linux/amd64",
"Created": 1573600782,
Expand All @@ -76,8 +76,8 @@
"Address": "54.194.252.215",
"Capacity": 2,
"Error": "",
"Image": "ami-cc4499a1",
"Size": "t2.medium",
"Image": "ami-0070c5311b7677678",
"Size": "t3.medium",
"Region": "us-east-1",
"Platform": "linux/amd64",
"Created": 1573600782,
Expand Down

0 comments on commit 79ea07e

Please sign in to comment.