forked from rebuy-de/aws-nuke
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bump the golang group with 1 update (rebuy-de#1188) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump the golang group with 1 update (rebuy-de#1191) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add release note config (rebuy-de#1192) * Add support for Redshift Serverless namespaces, snapshots and workgroups. (rebuy-de#1194) * feat: Adding Cloudfront response headers policies (rebuy-de#1140) * Bump the golang group with 1 update (rebuy-de#1195) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add ELB Listener Rules object (rebuy-de#1193) Co-authored-by: Philipp Trulson <[email protected]> * Bump the golang group with 2 updates (rebuy-de#1201) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump the golang group with 1 update (rebuy-de#1205) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add manual trigger to workflow (rebuy-de#1208) * Bump the golang group across 1 directory with 2 updates (rebuy-de#1217) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump github.com/aws/aws-sdk-go from 1.51.31 to 1.52.3 in the golang group (rebuy-de#1220) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump the golang group across 1 directory with 2 updates (rebuy-de#1227) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump github.com/aws/aws-sdk-go from 1.53.10 to 1.53.15 in the golang group (rebuy-de#1229) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add cloudformationiface mock (#19) --------- Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Philipp Trulson <[email protected]> Co-authored-by: Maarten Dirkse <[email protected]> Co-authored-by: Oliver Fletcher <[email protected]> Co-authored-by: Vincent Boulineau <[email protected]> Co-authored-by: Bradley Fisher <[email protected]>
- Loading branch information
1 parent
0b0a317
commit 42ab697
Showing
11 changed files
with
492 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes | ||
|
||
changelog: | ||
categories: | ||
- title: Notable changes | ||
labels: | ||
- '*' | ||
exclude: | ||
labels: | ||
- dependencies | ||
- title: Dependency updates | ||
labels: | ||
- dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package resources | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/cloudfront" | ||
"github.com/rebuy-de/aws-nuke/v2/pkg/types" | ||
) | ||
|
||
type CloudFrontResponseHeadersPolicy struct { | ||
svc *cloudfront.CloudFront | ||
ID *string | ||
name *string | ||
} | ||
|
||
func init() { | ||
register("CloudFrontResponseHeadersPolicy", ListCloudFrontResponseHeadersPolicies) | ||
} | ||
|
||
func ListCloudFrontResponseHeadersPolicies(sess *session.Session) ([]Resource, error) { | ||
svc := cloudfront.New(sess) | ||
resources := []Resource{} | ||
params := &cloudfront.ListResponseHeadersPoliciesInput{} | ||
|
||
for { | ||
resp, err := svc.ListResponseHeadersPolicies(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, item := range resp.ResponseHeadersPolicyList.Items { | ||
resources = append(resources, &CloudFrontResponseHeadersPolicy{ | ||
svc: svc, | ||
ID: item.ResponseHeadersPolicy.Id, | ||
name: item.ResponseHeadersPolicy.ResponseHeadersPolicyConfig.Name, | ||
}) | ||
} | ||
|
||
if resp.ResponseHeadersPolicyList.NextMarker == nil { | ||
break | ||
} | ||
|
||
params.Marker = resp.ResponseHeadersPolicyList.NextMarker | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
func (f *CloudFrontResponseHeadersPolicy) Filter() error { | ||
if strings.HasPrefix(*f.name, "Managed-") { | ||
return fmt.Errorf("Cannot delete default CloudFront Response headers policy") | ||
} | ||
return nil | ||
} | ||
|
||
func (f *CloudFrontResponseHeadersPolicy) Remove() error { | ||
resp, err := f.svc.GetResponseHeadersPolicy(&cloudfront.GetResponseHeadersPolicyInput{ | ||
Id: f.ID, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = f.svc.DeleteResponseHeadersPolicy(&cloudfront.DeleteResponseHeadersPolicyInput{ | ||
Id: f.ID, | ||
IfMatch: resp.ETag, | ||
}) | ||
|
||
return err | ||
} | ||
|
||
func (f *CloudFrontResponseHeadersPolicy) String() string { | ||
return *f.name | ||
} | ||
|
||
func (f *CloudFrontResponseHeadersPolicy) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
properties.Set("ID", f.ID) | ||
properties.Set("Name", f.name) | ||
return properties | ||
} |
Oops, something went wrong.