Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/workflow-plugin-aws/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"type": "external",
"tier": "community",
"minEngineVersion": "0.64.3",
"minEngineVersion": "0.68.2",
"iacServices": [
"workflow.plugin.external.iac.IaCProviderRequired",
"workflow.plugin.external.iac.IaCProviderEnumerator",
Expand Down
24 changes: 12 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/GoCodeAlone/workflow-plugin-aws
go 1.26.0

require (
github.com/GoCodeAlone/workflow v0.64.3
github.com/GoCodeAlone/workflow v0.68.2
github.com/aws/aws-sdk-go-v2 v1.41.7
github.com/aws/aws-sdk-go-v2/config v1.32.16
github.com/aws/aws-sdk-go-v2/credentials v1.19.15
Expand Down Expand Up @@ -31,12 +31,12 @@ require (
github.com/BurntSushi/toml v1.6.0 // indirect
github.com/DataDog/datadog-go/v5 v5.8.3 // indirect
github.com/GoCodeAlone/go-plugin v1.7.0 // indirect
github.com/GoCodeAlone/modular v1.13.0 // indirect
github.com/GoCodeAlone/modular/modules/auth v1.15.0 // indirect
github.com/GoCodeAlone/modular/modules/cache v1.15.0 // indirect
github.com/GoCodeAlone/modular/modules/eventbus/v2 v2.8.0 // indirect
github.com/GoCodeAlone/modular/modules/jsonschema v1.15.0 // indirect
github.com/GoCodeAlone/modular/modules/reverseproxy/v2 v2.8.0 // indirect
github.com/GoCodeAlone/modular v1.13.4 // indirect
github.com/GoCodeAlone/modular/modules/auth v1.17.0 // indirect
github.com/GoCodeAlone/modular/modules/cache v1.17.0 // indirect
github.com/GoCodeAlone/modular/modules/eventbus/v2 v2.10.0 // indirect
github.com/GoCodeAlone/modular/modules/jsonschema v1.17.0 // indirect
github.com/GoCodeAlone/modular/modules/reverseproxy/v2 v2.10.0 // indirect
github.com/GoCodeAlone/yaegi v0.17.2 // indirect
github.com/IBM/sarama v1.47.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
Expand All @@ -53,7 +53,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.12 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.22 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.20 // indirect
github.com/aws/aws-sdk-go-v2/service/kinesis v1.43.4 // indirect
github.com/aws/aws-sdk-go-v2/service/kinesis v1.43.5 // indirect
github.com/aws/aws-sdk-go-v2/service/signin v1.0.10 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.30.16 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.20 // indirect
Expand Down Expand Up @@ -84,7 +84,7 @@ require (
github.com/fatih/color v1.19.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/flowchartsman/retry v1.2.0 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/fsnotify/fsnotify v1.10.1 // indirect
github.com/fxamacker/cbor/v2 v2.9.2 // indirect
github.com/go-jose/go-jose/v4 v4.1.4 // indirect
github.com/go-logr/logr v1.4.3 // indirect
Expand Down Expand Up @@ -115,11 +115,11 @@ require (
github.com/hashicorp/memberlist v0.5.4 // indirect
github.com/hashicorp/vault/api v1.23.0 // indirect
github.com/hashicorp/yamux v0.1.2 // indirect
github.com/itchyny/gojq v0.12.18 // indirect
github.com/itchyny/timefmt-go v0.1.7 // indirect
github.com/itchyny/gojq v0.12.19 // indirect
github.com/itchyny/timefmt-go v0.1.8 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.9.1 // indirect
github.com/jackc/pgx/v5 v5.9.2 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
Expand Down
54 changes: 26 additions & 28 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,20 @@ github.com/DataDog/datadog-go/v5 v5.8.3 h1:s58CUJ9s8lezjhTNJO/SxkPBv2qZjS3ktpRSq
github.com/DataDog/datadog-go/v5 v5.8.3/go.mod h1:K9kcYBlxkcPP8tvvjZZKs/m1edNAUFzBbdpTUKfCsuw=
github.com/GoCodeAlone/go-plugin v1.7.0 h1:EwnhqPlXiNmp85S+MXnKKvm3YlfA6O4NzBb4+GSlEVY=
github.com/GoCodeAlone/go-plugin v1.7.0/go.mod h1:HbGQRZUIa+jbDfjsaZIMJYvrz+LnxL0mJpggfynSTMk=
github.com/GoCodeAlone/modular v1.13.0 h1:UfsegfAmPWcPYQOqYZFsw/LNySBmMDcthiOQe5bscqE=
github.com/GoCodeAlone/modular v1.13.0/go.mod h1:b06Pvgcc8HsGxvl30iO39zGH2jIWz467QEj2+OQL2Do=
github.com/GoCodeAlone/modular/modules/auth v1.15.0 h1:pBSkPSf4k4GLSbUQFLuPa+nFbfoJXGzSz9q89VoapZk=
github.com/GoCodeAlone/modular/modules/auth v1.15.0/go.mod h1:vmIm/LQrcURS2p02YwaELb+CZoHPtT0XB0v1i+sj9i4=
github.com/GoCodeAlone/modular/modules/cache v1.15.0 h1:6Y2EJ5S7mb/TjyG/uN6dto5VUYJNDFYULUamRsqAKvo=
github.com/GoCodeAlone/modular/modules/cache v1.15.0/go.mod h1:PRun74dRZKfqlBM+f6QrvI9oa4joUU3j1hisiLyQ+oM=
github.com/GoCodeAlone/modular/modules/eventbus/v2 v2.8.0 h1:buYs0TGNbAZgtTq1Qb+dfmTv3+ZOBIN0HbvVBLyNqxE=
github.com/GoCodeAlone/modular/modules/eventbus/v2 v2.8.0/go.mod h1:329flAKmwrPq2JEwu9iltWv6A83H/Di82Xze+kvdKDw=
github.com/GoCodeAlone/modular/modules/jsonschema v1.15.0 h1:xb1mI4NZkzvNKQ2F6nkyXQvK/kEvvfs1z7FoGf3/LRA=
github.com/GoCodeAlone/modular/modules/jsonschema v1.15.0/go.mod h1:hhGouwAVsonmJ4Lain4jINZ9nZCoc9l9eF3BHbmR8eE=
github.com/GoCodeAlone/modular/modules/reverseproxy/v2 v2.8.0 h1:cvdLHbM/vzvygQTcAWSJsy+dAPzzwWyjzKMmTBFcFIo=
github.com/GoCodeAlone/modular/modules/reverseproxy/v2 v2.8.0/go.mod h1:/9ipMG4qM2CHQ14BfXKdVlYRJelef6M8MFI5TbZv67M=
github.com/GoCodeAlone/workflow v0.64.0 h1:2CpbYPwIqdGDb3xi3YJpwcteIum4ehBSrnRql/1YvB4=
github.com/GoCodeAlone/workflow v0.64.0/go.mod h1:659GGDrw3QJ7b625y9rf8QhKIpt1VCoEG0MxKu5tGQs=
github.com/GoCodeAlone/workflow v0.64.3 h1:r0jMoRJXJI8lz44c70mFjGcpy24IWpOTtkX7BC0/fas=
github.com/GoCodeAlone/workflow v0.64.3/go.mod h1:659GGDrw3QJ7b625y9rf8QhKIpt1VCoEG0MxKu5tGQs=
github.com/GoCodeAlone/modular v1.13.4 h1:De4p2qyJSVmstRGno/PM+fPdUCMu/7a9WgU5FUVGDa8=
github.com/GoCodeAlone/modular v1.13.4/go.mod h1:+JEPUYOxGaD332EMZ5PbJCz5rxwvFu4Tm6MrnZT0vxM=
github.com/GoCodeAlone/modular/modules/auth v1.17.0 h1:GbKG6s/2qe6N9YZ8vtvYsNon56MLWECncPxWvAsazSc=
github.com/GoCodeAlone/modular/modules/auth v1.17.0/go.mod h1:E9dDIxiAxIrXK8gn/rEhaqI5OYe6Aw/uGpRyI7iyxj8=
github.com/GoCodeAlone/modular/modules/cache v1.17.0 h1:1cColHYfF7aFZhxBjS4RuZ2wBOYWAIVr5GkJ3nk5VIA=
github.com/GoCodeAlone/modular/modules/cache v1.17.0/go.mod h1:RURzRp+vpRzKR2LjZXwQ4QGc1cvE+53SYODcxY6AR3Y=
github.com/GoCodeAlone/modular/modules/eventbus/v2 v2.10.0 h1:2ljVafd/1LYchF47WrnA1+ji8mcmVXMJ4F5qDrhZZi4=
github.com/GoCodeAlone/modular/modules/eventbus/v2 v2.10.0/go.mod h1:AKLcRGsw5gp2Q1zhuK0TBnMJOsaRe3aJ2OKnLFE2O5w=
github.com/GoCodeAlone/modular/modules/jsonschema v1.17.0 h1:zoWioqUvuNNDfnjHA1sHixdlHfBreJdGhnnEBtxkzI8=
github.com/GoCodeAlone/modular/modules/jsonschema v1.17.0/go.mod h1:GDU/jsD6AddmXKedj0wZwieUIaQsTBSGMzuj+XHXMrw=
github.com/GoCodeAlone/modular/modules/reverseproxy/v2 v2.10.0 h1:+2M/ecyCxDiXfJM4ibcERuu/BBeIbLTQNcVgRsllR64=
github.com/GoCodeAlone/modular/modules/reverseproxy/v2 v2.10.0/go.mod h1:tlVH1mA5yuU8CB7R7+HXIRaBixZoNid6h+5tew5u3FU=
github.com/GoCodeAlone/workflow v0.68.2 h1:U0ksQOkIwDReuw+nz4kRoCeYwahoBaItqLzwYIRm758=
github.com/GoCodeAlone/workflow v0.68.2/go.mod h1:4UwFYm1cM8a/AvGNb1CZAuob0b0gq7552sxcNMdDALA=
github.com/GoCodeAlone/yaegi v0.17.2 h1:WK6Y6e0t1a6U7r+S2dN3CGWW1PizYD3zO0zneToZPxM=
github.com/GoCodeAlone/yaegi v0.17.2/go.mod h1:z5Pr6Wse6QJcQvpgxTxzMAevFarH0N37TG88Y9dprx0=
github.com/IBM/sarama v1.47.0 h1:GcQFEd12+KzfPYeLgN69Fh7vLCtYRhVIx0rO4TZO318=
Expand Down Expand Up @@ -96,8 +94,8 @@ github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.22 h1:PUmZeJU6
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.22/go.mod h1:nO6egFBoAaoXze24a2C0NjQCvdpk8OueRoYimvEB9jo=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.20 h1:siU1A6xjUZ2N8zjTHSXFhB9L/2OY8Dqs0xXiLjF30jA=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.20/go.mod h1:4TLZCmVJDM3FOu5P5TJP0zOlu9zWgDWU7aUxWbr+rcw=
github.com/aws/aws-sdk-go-v2/service/kinesis v1.43.4 h1:3m9iJtMtLq75jKRAfw0kapoHUlbzi0CRVigysBN/FHA=
github.com/aws/aws-sdk-go-v2/service/kinesis v1.43.4/go.mod h1:O2L6vGm4xacEuN2otHFMgn7yXXlgzFKzxrba0fy/yk8=
github.com/aws/aws-sdk-go-v2/service/kinesis v1.43.5 h1:LxgRVyuY+5DEPSX7kmin/V7toE8MWZ9U8n2dqRtX+RE=
github.com/aws/aws-sdk-go-v2/service/kinesis v1.43.5/go.mod h1:eUebEBEqVfOwEyDDDbGauH4PNqDCuepRvTaNbJeWr5w=
github.com/aws/aws-sdk-go-v2/service/rds v1.115.0 h1:oNl6YghOtxu3MiFk1tQ86QlrYMIEJazGUDbBCg9nxLA=
github.com/aws/aws-sdk-go-v2/service/rds v1.115.0/go.mod h1:JBRYWpz5oXQtHgQC+X8LX9lh0FBCwRHJlWEIT+TTLaE=
github.com/aws/aws-sdk-go-v2/service/route53 v1.62.5 h1:Z+/OLsb85Kpq7TVLCspskqePaf68Tdv6GfmJP4kH6i0=
Expand Down Expand Up @@ -206,12 +204,12 @@ github.com/flowchartsman/retry v1.2.0 h1:qDhlw6RNufXz6RGr+IiYimFpMMkt77SUSHY5tgF
github.com/flowchartsman/retry v1.2.0/go.mod h1:+sfx8OgCCiAr3t5jh2Gk+T0fRTI+k52edaYxURQxY64=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho=
github.com/fsnotify/fsnotify v1.10.1/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo=
github.com/fxamacker/cbor/v2 v2.9.2 h1:X4Ksno9+x3cz0TZv69ec1hxP/+tymuR8PXQJyDwfh78=
github.com/fxamacker/cbor/v2 v2.9.2/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
github.com/go-chi/chi/v5 v5.2.2 h1:CMwsvRVTbXVytCk1Wd72Zy1LAsAh9GxMmSNWLHCG618=
github.com/go-chi/chi/v5 v5.2.2/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops=
github.com/go-chi/chi/v5 v5.2.5 h1:Eg4myHZBjyvJmAFjFvWgrqDTXFyOzjj7YIm3L3mu6Ug=
github.com/go-chi/chi/v5 v5.2.5/go.mod h1:X7Gx4mteadT3eDOMTsXzmI4/rwUpOwBHLpAfupzFJP0=
github.com/go-jose/go-jose/v4 v4.1.4 h1:moDMcTHmvE6Groj34emNPLs/qtYXRVcd6S7NHbHz3kA=
github.com/go-jose/go-jose/v4 v4.1.4/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
Expand Down Expand Up @@ -363,16 +361,16 @@ github.com/hashicorp/vault/api v1.23.0 h1:gXgluBsSECfRWTSW9niY2jwg2e9mMJc4WoHNv4
github.com/hashicorp/vault/api v1.23.0/go.mod h1:zransKiB9ftp+kgY8ydjnvCU7Wk8i9L0DYWpXeMj9ko=
github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8=
github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns=
github.com/itchyny/gojq v0.12.18 h1:gFGHyt/MLbG9n6dqnvlliiya2TaMMh6FFaR2b1H6Drc=
github.com/itchyny/gojq v0.12.18/go.mod h1:4hPoZ/3lN9fDL1D+aK7DY1f39XZpY9+1Xpjz8atrEkg=
github.com/itchyny/timefmt-go v0.1.7 h1:xyftit9Tbw+Dc/huSSPJaEmX1TVL8lw5vxjJLK4GMMA=
github.com/itchyny/timefmt-go v0.1.7/go.mod h1:5E46Q+zj7vbTgWY8o5YkMeYb4I6GeWLFnetPy5oBrAI=
github.com/itchyny/gojq v0.12.19 h1:ttXA0XCLEMoaLOz5lSeFOZ6u6Q3QxmG46vfgI4O0DEs=
github.com/itchyny/gojq v0.12.19/go.mod h1:5galtVPDywX8SPSOrqjGxkBeDhSxEW1gSxoy7tn1iZY=
github.com/itchyny/timefmt-go v0.1.8 h1:1YEo1JvfXeAHKdjelbYr/uCuhkybaHCeTkH8Bo791OI=
github.com/itchyny/timefmt-go v0.1.8/go.mod h1:5E46Q+zj7vbTgWY8o5YkMeYb4I6GeWLFnetPy5oBrAI=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.9.1 h1:uwrxJXBnx76nyISkhr33kQLlUqjv7et7b9FjCen/tdc=
github.com/jackc/pgx/v5 v5.9.1/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
github.com/jackc/pgx/v5 v5.9.2 h1:3ZhOzMWnR4yJ+RW1XImIPsD1aNSz4T4fyP7zlQb56hw=
github.com/jackc/pgx/v5 v5.9.2/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
Expand Down
2 changes: 2 additions & 0 deletions internal/iacserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type awsIaCServer struct {
pb.UnimplementedIaCProviderValidatorServer
pb.UnimplementedIaCProviderDriftConfigDetectorServer
pb.UnimplementedIaCProviderRequirementMapperServer
pb.UnimplementedIaCProviderRegionListerServer
pb.UnimplementedResourceDriverServer
pb.UnimplementedIaCStateBackendServer

Expand Down Expand Up @@ -87,6 +88,7 @@ var (
_ pb.IaCProviderDriftDetectorServer = (*awsIaCServer)(nil)
_ pb.ResourceDriverServer = (*awsIaCServer)(nil)
_ pb.IaCProviderRequirementMapperServer = (*awsIaCServer)(nil)
_ pb.IaCProviderRegionListerServer = (*awsIaCServer)(nil)
// awsIaCServer also SERVES the typed IaC state-backend contract (s3
// backend). The SDK serve hook auto-registers this via type-assertion at
// plugin startup — see cmd/workflow-plugin-aws/main.go.
Expand Down
4 changes: 2 additions & 2 deletions internal/iacserver_mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ func TestPluginManifestAdvertisesRequirementMapper(t *testing.T) {
if err := json.Unmarshal(data, &manifest); err != nil {
t.Fatalf("parse plugin.json: %v", err)
}
if manifest.MinEngineVersion != "0.64.3" {
t.Fatalf("minEngineVersion = %q, want 0.64.3", manifest.MinEngineVersion)
if manifest.MinEngineVersion != "0.68.2" {
t.Fatalf("minEngineVersion = %q, want 0.68.2", manifest.MinEngineVersion)
}
const mapperService = "workflow.plugin.external.iac.IaCProviderRequirementMapper"
for _, svc := range manifest.IaCServices {
Expand Down
86 changes: 86 additions & 0 deletions internal/region_lister.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package internal

import (
"context"
"sort"

pb "github.com/GoCodeAlone/workflow/plugin/external/proto"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/ec2"
)

var awsFallbackRegions = []string{
"af-south-1",
"ap-east-1",
"ap-east-2",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-south-1",
"ap-south-2",
"ap-southeast-1",
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ap-southeast-7",
"ca-central-1",
"ca-west-1",
"eu-central-1",
"eu-central-2",
"eu-north-1",
"eu-south-1",
"eu-south-2",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"il-central-1",
"me-central-1",
"me-south-1",
"mx-central-1",
"sa-east-1",
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
}

func (s *awsIaCServer) ListRegions(ctx context.Context, _ *pb.ListRegionsRequest) (*pb.ListRegionsResponse, error) {
if s != nil && s.provider != nil {
cfg, ok := s.provider.AWSConfigSnapshot()
if ok {
regions, err := listAWSRegions(ctx, cfg)
if err == nil {
return providerRegionsResponse(regions), nil
}
}
Comment thread
intel352 marked this conversation as resolved.
}
return providerRegionsResponse(awsFallbackRegions), nil
}

func listAWSRegions(ctx context.Context, cfg aws.Config) ([]string, error) {
resp, err := ec2.NewFromConfig(cfg).DescribeRegions(ctx, &ec2.DescribeRegionsInput{
AllRegions: aws.Bool(true),
})
if err != nil {
return nil, err
}
regions := make([]string, 0, len(resp.Regions))
for _, region := range resp.Regions {
if region.RegionName != nil && *region.RegionName != "" {
regions = append(regions, *region.RegionName)
}
}
return regions, nil
}

func providerRegionsResponse(regions []string) *pb.ListRegionsResponse {
regions = append([]string(nil), regions...)
sort.Strings(regions)

out := make([]*pb.ProviderRegion, 0, len(regions))
for _, name := range regions {
out = append(out, &pb.ProviderRegion{Name: name, DisplayName: name})
}
return &pb.ListRegionsResponse{Regions: out}
}
86 changes: 86 additions & 0 deletions internal/region_lister_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package internal

import (
"context"
"encoding/json"
"os"
"path/filepath"
"sort"
"testing"

"github.com/GoCodeAlone/workflow-plugin-aws/provider"
pb "github.com/GoCodeAlone/workflow/plugin/external/proto"
sdk "github.com/GoCodeAlone/workflow/plugin/external/sdk"
"google.golang.org/grpc"
)

func TestAWSIaCServer_ListRegions(t *testing.T) {
resp, err := NewIaCServer().ListRegions(context.Background(), &pb.ListRegionsRequest{EnvName: "prod"})
if err != nil {
t.Fatalf("ListRegions: %v", err)
}
got := regionNames(resp.GetRegions())
want := append([]string(nil), awsFallbackRegions...)
sort.Strings(want)
if !sameStrings(got, want) {
Comment thread
intel352 marked this conversation as resolved.
Comment thread
intel352 marked this conversation as resolved.
Comment thread
intel352 marked this conversation as resolved.
t.Fatalf("regions = %v, want %v", got, want)
}
}

func TestAWSIaCServer_RegistersRegionLister(t *testing.T) {
server := grpc.NewServer()
if err := sdk.RegisterAllIaCProviderServices(server, newAWSIaCServer(provider.NewAWSProviderConcrete())); err != nil {
t.Fatalf("RegisterAllIaCProviderServices: %v", err)
}
if _, ok := server.GetServiceInfo()[pb.IaCProviderRegionLister_ServiceDesc.ServiceName]; !ok {
t.Fatalf("registered services missing %s", pb.IaCProviderRegionLister_ServiceDesc.ServiceName)
}
}

func TestPluginManifestAdvertisesRegionLister(t *testing.T) {
data, err := os.ReadFile(filepath.Join(hostConformanceRepoRoot(t), "plugin.json"))
if err != nil {
t.Fatalf("read plugin.json: %v", err)
}
var manifest struct {
IaCServices []string `json:"iacServices"`
}
if err := json.Unmarshal(data, &manifest); err != nil {
t.Fatalf("parse plugin.json: %v", err)
}
if !containsString(manifest.IaCServices, pb.IaCProviderRegionLister_ServiceDesc.ServiceName) {
t.Fatalf("iacServices missing %s: %v", pb.IaCProviderRegionLister_ServiceDesc.ServiceName, manifest.IaCServices)
}
}

func regionNames(regions []*pb.ProviderRegion) []string {
out := make([]string, 0, len(regions))
for _, region := range regions {
out = append(out, region.GetName())
if region.GetDisplayName() == "" {
out = append(out, "<empty-display>")
}
}
return out
}

func sameStrings(a, b []string) bool {
if len(a) != len(b) {
return false
}
for i := range a {
if a[i] != b[i] {
return false
}
}
return true
}

func containsString(values []string, want string) bool {
for _, value := range values {
if value == want {
return true
}
}
return false
}
3 changes: 2 additions & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"type": "external",
"tier": "community",
"minEngineVersion": "0.64.3",
"minEngineVersion": "0.68.2",
"required_secrets": [
{
"name": "AWS_ACCESS_KEY_ID",
Expand All @@ -30,6 +30,7 @@
"workflow.plugin.external.iac.IaCProviderValidator",
"workflow.plugin.external.iac.IaCProviderDriftConfigDetector",
"workflow.plugin.external.iac.IaCProviderRequirementMapper",
"workflow.plugin.external.iac.IaCProviderRegionLister",
"workflow.plugin.external.iac.ResourceDriver",
"workflow.plugin.external.iac.IaCStateBackend"
],
Expand Down
8 changes: 8 additions & 0 deletions provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ func NewAWSProviderConcrete() *AWSProvider {
func (p *AWSProvider) Name() string { return ProviderName }
func (p *AWSProvider) Version() string { return ProviderVersion }

// AWSConfigSnapshot returns the initialized AWS SDK config for typed services
// that need to call provider APIs outside the resource-driver path.
func (p *AWSProvider) AWSConfigSnapshot() (awssdk.Config, bool) {
p.mu.RLock()
defer p.mu.RUnlock()
return p.cfg, p.initialized
}

// Initialize configures the AWS SDK and registers all resource drivers.
//
// Supported config keys (back-compat top-level):
Expand Down
Loading