File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package resources
2+
3+ import (
4+ "github.com/aws/aws-sdk-go/aws/session"
5+ "github.com/aws/aws-sdk-go/service/cloudfront"
6+ )
7+
8+ type CloudFrontOriginAccessIdentity struct {
9+ svc * cloudfront.CloudFront
10+ ID * string
11+ }
12+
13+ func init () {
14+ register ("CloudFrontOriginAccessIdentity" , ListCloudFrontOriginAccessIdentities )
15+ }
16+
17+ func ListCloudFrontOriginAccessIdentities (sess * session.Session ) ([]Resource , error ) {
18+ svc := cloudfront .New (sess )
19+ resources := []Resource {}
20+
21+ for {
22+ resp , err := svc .ListCloudFrontOriginAccessIdentities (nil )
23+ if err != nil {
24+ return nil , err
25+ }
26+
27+ for _ , identity := range resp .CloudFrontOriginAccessIdentityList .Items {
28+ resources = append (resources ,& CloudFrontOriginAccessIdentity {
29+ svc : svc ,
30+ ID : item .Id ,
31+ })
32+ }
33+ return resources , nil
34+ }
35+ }
36+
37+ func (f * CloudFrontOriginAccessIdentity ) Remove () error {
38+ resp , err := f .svc .GetCloudFrontOriginAccessIdentity (& cloudfront.GetCloudFrontOriginAccessIdentityInput {
39+ Id : f .ID ,
40+ })
41+ if err != nil {
42+ return err
43+ }
44+
45+ _ , err = f .svc .DeleteCloudFrontOriginAccessIdentity (& cloudfront.DeleteCloudFrontOriginAccessIdentityInput {
46+ Id : f .ID ,
47+ IfMatch : resp .ETag ,
48+ })
49+
50+ return err
51+ }
52+
53+ func (f * CloudFrontOriginAccessIdentity ) String () string {
54+ return * f .ID
55+ }
You can’t perform that action at this time.
0 commit comments