Skip to content

Commit 4feb155

Browse files
committed
Add support for filtering expected resource types
Add optional resource-types input parameter that allows specifying which AWS resource types the stack update is expected to change. The value is passed to CloudFormation UpdateStack API as ResourceTypes parameter.
1 parent b99d383 commit 4feb155

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ inputs:
1111
Newline-separated parameters to change in the Name=Value format.
1212
Stack parameters not set here would retain their existing values.
1313
required: true
14+
resource-types:
15+
description: >
16+
Optional newline-separated AWS resource types that stack update is expected to change.
1417
1518
runs:
1619
using: docker

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
module github.com/artyom/update-cloudformation-stack
22

3-
go 1.23.3
3+
go 1.25.0
44

55
require (
6+
github.com/aws/aws-sdk-go-v2 v1.32.5
67
github.com/aws/aws-sdk-go-v2/config v1.28.5
78
github.com/aws/aws-sdk-go-v2/service/cloudformation v1.56.0
89
github.com/aws/smithy-go v1.22.1
910
)
1011

1112
require (
12-
github.com/aws/aws-sdk-go-v2 v1.32.5 // indirect
1313
github.com/aws/aws-sdk-go-v2/credentials v1.17.46 // indirect
1414
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20 // indirect
1515
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24 // indirect

main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ func run(ctx context.Context, stackName string, args []string) error {
5252
return errors.New("empty parameters list")
5353
}
5454
debugf("loaded parameters: %v", toReplace)
55+
var resourceTypes []string
56+
if val := os.Getenv("INPUT_RESOURCE-TYPES"); val != "" {
57+
for s := range strings.Lines(val) {
58+
if s = strings.TrimSpace(s); s != "" {
59+
resourceTypes = append(resourceTypes, s)
60+
}
61+
}
62+
}
63+
debugf("resource types: %v", resourceTypes)
5564
cfg, err := config.LoadDefaultConfig(ctx)
5665
if err != nil {
5766
return err
@@ -96,6 +105,7 @@ func run(ctx context.Context, stackName string, args []string) error {
96105
ClientRequestToken: &token,
97106
UsePreviousTemplate: ptr(true),
98107
Parameters: params,
108+
ResourceTypes: resourceTypes,
99109
Capabilities: stack.Capabilities,
100110
NotificationARNs: stack.NotificationARNs,
101111
})

0 commit comments

Comments
 (0)