Skip to content

Commit 336fed8

Browse files
authored
Merge pull request #33 from oreillymedia/CL-937-bedrock
Cl 937 bedrock
2 parents b1363ac + 2e67160 commit 336fed8

File tree

5 files changed

+359
-11
lines changed

5 files changed

+359
-11
lines changed

.editorconfig

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Distributed via https://github.com/rebuy-de/terraform-cluster-config
2+
# Modify only there, changes in project repos will be overwritten
3+
4+
root = true
5+
6+
[openapi-spec.yaml]
7+
ij_formatter_enabled = false
8+
9+
[*]
10+
charset = utf-8
11+
end_of_line = lf
12+
indent_size = 4
13+
indent_style = space
14+
insert_final_newline = true
15+
max_line_length = 120
16+
tab_width = 4
17+
trim_trailing_whitespace = true
18+
ij_continuation_indent_size = 8
19+
ij_formatter_off_tag = @formatter:off
20+
ij_formatter_on_tag = @formatter:on
21+
ij_formatter_tags_enabled = true
22+
ij_smart_tabs = false
23+
ij_visual_guides =
24+
ij_wrap_on_typing = false
25+
26+
[{*.htm,*.html,*.sht,*.shtm,*.shtml}]
27+
ij_html_attribute_wrap = off
28+
ij_html_do_not_indent_children_of_tags =
29+
ij_html_keep_blank_lines = 1
30+
ij_html_text_wrap = off
31+
32+
[{*.cjs,*.js}]
33+
ij_javascript_do_while_brace_force = always
34+
ij_javascript_for_brace_force = always
35+
ij_javascript_if_brace_force = always
36+
ij_javascript_keep_blank_lines_in_code = 1
37+
ij_javascript_use_double_quotes = false
38+
ij_javascript_while_brace_force = always
39+
40+
[{*.ats,*.cts,*.mts,*.ts}]
41+
ij_typescript_do_while_brace_force = always
42+
ij_typescript_for_brace_force = always
43+
ij_typescript_if_brace_force = always
44+
ij_typescript_import_prefer_absolute_path = true
45+
ij_typescript_keep_blank_lines_in_code = 1
46+
ij_typescript_space_before_function_left_parenth = false
47+
ij_typescript_use_double_quotes = false
48+
ij_typescript_while_brace_force = always
49+
50+
[*.coffee]
51+
indent_size = 2
52+
53+
[*.java]
54+
ij_continuation_indent_size = 4
55+
ij_java_blank_lines_around_field = 1
56+
ij_java_blank_lines_around_initializer = 0
57+
ij_java_class_brace_style = next_line
58+
ij_java_class_count_to_use_import_on_demand = 99
59+
ij_java_do_while_brace_force = always
60+
ij_java_doc_add_blank_line_after_param_comments = true
61+
ij_java_doc_add_blank_line_after_return = true
62+
ij_java_for_brace_force = always
63+
ij_java_if_brace_force = always
64+
ij_java_keep_blank_lines_before_right_brace = 0
65+
ij_java_keep_blank_lines_in_code = 1
66+
ij_java_keep_blank_lines_in_declarations = 0
67+
ij_java_keep_simple_classes_in_one_line = true
68+
ij_java_keep_simple_lambdas_in_one_line = true
69+
ij_java_method_brace_style = next_line
70+
ij_java_names_count_to_use_import_on_demand = 99
71+
ij_java_new_line_after_lparen_in_record_header = true
72+
ij_java_packages_to_use_import_on_demand =
73+
ij_java_record_components_wrap = on_every_item
74+
ij_java_rparen_on_new_line_in_record_header = true
75+
ij_java_while_brace_force = always
76+
77+
[{*.kt,*.kts}]
78+
ij_continuation_indent_size = 4
79+
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
80+
ij_kotlin_name_count_to_use_star_import = 2147483647
81+
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
82+
ij_kotlin_packages_to_use_import_on_demand =
83+
84+
[{*.ctp,*.hphp,*.inc,*.module,*.php,*.php4,*.php5,*.phtml}]
85+
ij_php_align_multiline_parameters = false
86+
ij_php_blank_lines_around_field = 1
87+
ij_php_blank_lines_before_return_statement = 1
88+
ij_php_comma_after_last_array_element = true
89+
ij_php_force_short_declaration_array_style = true
90+
ij_php_keep_blank_lines_before_right_brace = 0
91+
ij_php_keep_blank_lines_in_code = 1
92+
ij_php_keep_blank_lines_in_declarations = 0
93+
ij_php_keep_rparen_and_lbrace_on_one_line = true
94+
ij_php_lower_case_boolean_const = true
95+
ij_php_lower_case_null_const = true
96+
ij_php_method_parameters_new_line_after_left_paren = true
97+
ij_php_method_parameters_right_paren_on_new_line = true
98+
ij_php_phpdoc_blank_line_before_tags = true
99+
ij_php_phpdoc_blank_lines_around_parameters = true
100+
ij_php_space_after_type_cast = true
101+
ij_php_space_before_short_closure_left_parenthesis = true
102+
103+
[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.pom,*.rng,*.tld,*.wadl,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul,phpunit.xml.dist}]
104+
ij_xml_space_inside_empty_tag = true
105+
106+
[{*.tf,*.tfvars,*.hcl}]
107+
tab_width = 2
108+
ij_continuation_indent_size = 4
109+
110+
[*.less]
111+
tab_width = 2
112+
ij_continuation_indent_size = 2
113+
114+
[*.sass]
115+
tab_width = 2
116+
ij_continuation_indent_size = 2
117+
118+
[*.scala]
119+
ij_scala_do_while_brace_force = always
120+
ij_scala_for_brace_force = always
121+
ij_scala_if_brace_force = always
122+
ij_scala_keep_blank_lines_before_right_brace = 0
123+
ij_scala_keep_blank_lines_in_code = 0
124+
ij_scala_keep_blank_lines_in_declarations = 0
125+
ij_scala_multiline_string_closing_quotes_on_new_line = false
126+
127+
[*.scss]
128+
ij_continuation_indent_size = 4
129+
130+
[{*.yaml,*.yml}]
131+
ij_yaml_spaces_within_braces = false
132+
ij_yaml_spaces_within_brackets = false

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ module github.com/rebuy-de/aws-nuke/v2
33
go 1.21
44

55
require (
6-
github.com/aws/aws-sdk-go v1.53.10
6+
github.com/aws/aws-sdk-go v1.54.19
77
github.com/fatih/color v1.17.0
88
github.com/golang/mock v1.6.0
99
github.com/google/uuid v1.6.0
1010
github.com/mb0/glob v0.0.0-20160210091149-1eb79d2de6c4
1111
github.com/pkg/errors v0.9.1
1212
github.com/rebuy-de/rebuy-go-sdk/v4 v4.5.1
1313
github.com/sirupsen/logrus v1.9.3
14-
github.com/spf13/cobra v1.8.0
14+
github.com/spf13/cobra v1.8.1
1515
github.com/stretchr/testify v1.9.0
1616
golang.org/x/sync v0.7.0
1717
gopkg.in/yaml.v3 v3.0.1

go.sum

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
github.com/aws/aws-sdk-go v1.53.10 h1:3enP5l5WtezT9Ql+XZqs56JBf5YUd/FEzTCg///OIGY=
2-
github.com/aws/aws-sdk-go v1.53.10/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
3-
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
1+
github.com/aws/aws-sdk-go v1.54.19 h1:tyWV+07jagrNiCcGRzRhdtVjQs7Vy41NwsuOcl0IbVI=
2+
github.com/aws/aws-sdk-go v1.54.19/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
3+
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
44
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
55
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
66
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -44,8 +44,8 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
4444
github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
4545
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
4646
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
47-
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
48-
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
47+
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
48+
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
4949
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
5050
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
5151
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -64,8 +64,6 @@ golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
6464
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
6565
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
6666
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
67-
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
68-
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
6967
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
7068
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
7169
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
@@ -84,8 +82,6 @@ golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
8482
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
8583
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
8684
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
87-
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
88-
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
8985
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
9086
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
9187
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=

resources/bedrock-agentalias.go

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
package resources
2+
3+
import (
4+
"github.com/aws/aws-sdk-go/aws"
5+
"github.com/aws/aws-sdk-go/aws/session"
6+
"github.com/aws/aws-sdk-go/service/bedrockagent"
7+
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
8+
)
9+
10+
type BedrockAgentAlias struct {
11+
svc *bedrockagent.BedrockAgent
12+
AgentId *string
13+
AgentAliasId *string
14+
AgentAliasName *string
15+
}
16+
17+
func init() {
18+
register("BedrockAgentAlias", ListBedrockAgentAliases)
19+
}
20+
21+
func ListBedrockAgentAliases(sess *session.Session) ([]Resource, error) {
22+
svc := bedrockagent.New(sess)
23+
resources := []Resource{}
24+
25+
agentIds, err := ListBedrockAgentIds(svc)
26+
if err != nil {
27+
return nil, err
28+
}
29+
30+
for _, agentId := range agentIds {
31+
params := &bedrockagent.ListAgentAliasesInput{
32+
MaxResults: aws.Int64(100),
33+
AgentId: aws.String(agentId),
34+
}
35+
for {
36+
output, err := svc.ListAgentAliases(params)
37+
if err != nil {
38+
return nil, err
39+
}
40+
41+
for _, agentAliasInfo := range output.AgentAliasSummaries {
42+
resources = append(resources, &BedrockAgentAlias{
43+
svc: svc,
44+
AgentId: aws.String(agentId),
45+
AgentAliasName: agentAliasInfo.AgentAliasName,
46+
AgentAliasId: agentAliasInfo.AgentAliasId,
47+
})
48+
}
49+
50+
if output.NextToken == nil {
51+
break
52+
}
53+
params.NextToken = output.NextToken
54+
}
55+
56+
}
57+
58+
return resources, nil
59+
}
60+
61+
func ListBedrockAgentIds(svc *bedrockagent.BedrockAgent) ([]string, error) {
62+
63+
agentIds := []string{}
64+
params := &bedrockagent.ListAgentsInput{
65+
MaxResults: aws.Int64(100),
66+
}
67+
for {
68+
output, err := svc.ListAgents(params)
69+
if err != nil {
70+
return nil, err
71+
}
72+
73+
for _, agent := range output.AgentSummaries {
74+
agentIds = append(agentIds, *agent.AgentId)
75+
}
76+
77+
if output.NextToken == nil {
78+
break
79+
}
80+
params.NextToken = output.NextToken
81+
}
82+
83+
return agentIds, nil
84+
}
85+
86+
func (f *BedrockAgentAlias) Remove() error {
87+
_, err := f.svc.DeleteAgentAlias(&bedrockagent.DeleteAgentAliasInput{
88+
AgentAliasId: f.AgentAliasId,
89+
AgentId: f.AgentId,
90+
})
91+
return err
92+
}
93+
94+
func (f *BedrockAgentAlias) Properties() types.Properties {
95+
properties := types.NewProperties().
96+
Set("AgentId", f.AgentId).
97+
Set("AgentAliasId", f.AgentAliasId).
98+
Set("AgentAliasName", f.AgentAliasName)
99+
100+
return properties
101+
}
102+
103+
func (f *BedrockAgentAlias) String() string {
104+
return *f.AgentAliasName
105+
}

0 commit comments

Comments
 (0)