Skip to content

Commit 07d0ffa

Browse files
authored
feat(appsync-api): add new resource (#741)
* feat(appsync-api): add new resource * docs(appsync-api): generate docs
1 parent 718f9b4 commit 07d0ffa

File tree

3 files changed

+110
-2
lines changed

3 files changed

+110
-2
lines changed

docs/resources/app-sync-api.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
generated: true
3+
---
4+
5+
# AppSyncAPI
6+
7+
8+
## Resource
9+
10+
```text
11+
AppSyncAPI
12+
```
13+
14+
## Properties
15+
16+
17+
- `ID`: No Description
18+
- `tag:<key>:`: This resource has tags with property `Tags`. These are key/value pairs that are
19+
added as their own property with the prefix of `tag:` (e.g. [tag:example: "value"])
20+
21+
!!! note - Using Properties
22+
Properties are what [Filters](../config-filtering.md) are written against in your configuration. You use the property
23+
names to write filters for what you want to **keep** and omit from the nuke process.
24+
25+
### String Property
26+
27+
The string representation of a resource is generally the value of the Name, ID or ARN field of the resource. Not all
28+
resources support properties. To write a filter against the string representation, simply omit the `property` field in
29+
the filter.
30+
31+
The string value is always what is used in the output of the log format when a resource is identified.
32+

mkdocs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ nav:
167167
- App Stream Stack Fleet Attachment: resources/app-stream-stack-fleet-attachment.md
168168
- App Stream Stack: resources/app-stream-stack.md
169169
- App Sync Api Association: resources/app-sync-api-association.md
170+
- App Sync Api: resources/app-sync-api.md
170171
- App Sync Domain Name: resources/app-sync-domain-name.md
171172
- App Sync Graphql Api: resources/app-sync-graphql-api.md
172173
- Application Auto Scaling Scalable Target: resources/application-auto-scaling-scalable-target.md
@@ -184,12 +185,10 @@ nav:
184185
- Batch Compute Environment: resources/batch-compute-environment.md
185186
- Batch Job Queue State: resources/batch-job-queue-state.md
186187
- Batch Job Queue: resources/batch-job-queue.md
187-
- Bedrock Agent Alias: resources/bedrock-agent-alias.md
188188
- Bedrock Agent: resources/bedrock-agent.md
189189
- Bedrock Custom Model: resources/bedrock-custom-model.md
190190
- Bedrock Data Source: resources/bedrock-data-source.md
191191
- Bedrock Evaluation Job: resources/bedrock-evaluation-job.md
192-
- Bedrock Flow Alias: resources/bedrock-flow-alias.md
193192
- Bedrock Guardrail: resources/bedrock-guardrail.md
194193
- Bedrock Knowledge Base: resources/bedrock-knowledge-base.md
195194
- Bedrock Model Customization Job: resources/bedrock-model-customization-job.md

resources/appsync-api.go

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package resources
2+
3+
import (
4+
"context"
5+
6+
"github.com/aws/aws-sdk-go-v2/service/appsync"
7+
8+
"github.com/ekristen/libnuke/pkg/registry"
9+
"github.com/ekristen/libnuke/pkg/resource"
10+
"github.com/ekristen/libnuke/pkg/types"
11+
12+
"github.com/ekristen/aws-nuke/v3/pkg/nuke"
13+
)
14+
15+
const AppSyncAPIResource = "AppSyncAPI"
16+
17+
func init() {
18+
registry.Register(&registry.Registration{
19+
Name: AppSyncAPIResource,
20+
Scope: nuke.Account,
21+
Resource: &AppSyncAPI{},
22+
Lister: &AppSyncAPILister{},
23+
})
24+
}
25+
26+
type AppSyncAPILister struct{}
27+
28+
func (l *AppSyncAPILister) List(ctx context.Context, o interface{}) ([]resource.Resource, error) {
29+
opts := o.(*nuke.ListerOpts)
30+
svc := appsync.NewFromConfig(*opts.Config)
31+
var resources []resource.Resource
32+
33+
params := &appsync.ListApisInput{}
34+
35+
for {
36+
resp, err := svc.ListApis(ctx, params)
37+
if err != nil {
38+
return nil, err
39+
}
40+
41+
for _, p := range resp.Apis {
42+
resources = append(resources, &AppSyncAPI{
43+
svc: svc,
44+
ID: p.ApiId,
45+
Tags: p.Tags,
46+
})
47+
}
48+
49+
if resp.NextToken == nil {
50+
break
51+
}
52+
params.NextToken = resp.NextToken
53+
}
54+
55+
return resources, nil
56+
}
57+
58+
type AppSyncAPI struct {
59+
svc *appsync.Client
60+
ID *string
61+
Tags map[string]string
62+
}
63+
64+
func (r *AppSyncAPI) Remove(ctx context.Context) error {
65+
_, err := r.svc.DeleteApi(ctx, &appsync.DeleteApiInput{
66+
ApiId: r.ID,
67+
})
68+
return err
69+
}
70+
71+
func (r *AppSyncAPI) Properties() types.Properties {
72+
return types.NewPropertiesFromStruct(r)
73+
}
74+
75+
func (r *AppSyncAPI) String() string {
76+
return *r.ID
77+
}

0 commit comments

Comments
 (0)