Skip to content

Commit c862572

Browse files
committed
feat(aws): Create a resourceGroup that contains all the resources that we create
reference: NITRIC-18
1 parent 726004d commit c862572

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pkg/provider/pulumi/aws/aws.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ package aws
1818

1919
import (
2020
"context"
21+
"encoding/json"
2122
"io/ioutil"
2223
"os"
2324

2425
"github.com/pkg/errors"
2526
"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/dynamodb"
2627
"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ecr"
28+
"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/resourcegroups"
2729
"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/s3"
2830
"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/sns"
2931
"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/sqs"
@@ -75,6 +77,28 @@ func (a *awsProvider) Deploy(ctx *pulumi.Context) error {
7577
return err
7678
}
7779

80+
rgQueryJSON, err := json.Marshal(map[string]interface{}{
81+
"ResourceTypeFilters": []string{"AWS::AllSupported"},
82+
"TagFilters": []interface{}{
83+
map[string]interface{}{
84+
"Key": "x-nitric-stack",
85+
"Values": []string{ctx.Stack()},
86+
},
87+
},
88+
})
89+
if err != nil {
90+
return errors.WithMessage(err, "resource group json marshal")
91+
}
92+
93+
_, err = resourcegroups.NewGroup(ctx, ctx.Stack(), &resourcegroups.GroupArgs{
94+
ResourceQuery: &resourcegroups.GroupResourceQueryArgs{
95+
Query: pulumi.String(rgQueryJSON),
96+
},
97+
})
98+
if err != nil {
99+
return errors.WithMessage(err, "resource group create")
100+
}
101+
78102
topics := map[string]*sns.Topic{}
79103
for k := range a.s.Topics {
80104
topics[k], err = sns.NewTopic(ctx, k, &sns.TopicArgs{Tags: commonTags(ctx, k)})

0 commit comments

Comments
 (0)