-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afae149
commit 206306d
Showing
6 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
Binary file not shown.
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,44 @@ | ||
package awshandler | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
"github.com/Cloud-Code-AI/cloudstate/services/utils" | ||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/service/cloudfront" | ||
"github.com/aws/aws-sdk-go-v2/service/cloudfront/types" | ||
) | ||
|
||
type CloudfrontList struct { | ||
Distributions []types.DistributionSummary `json:"websites"` | ||
} | ||
|
||
// Gets all the distribution of cloudfront for a given regions and | ||
// stores the results in output/{region}/cloudfront/distributions.json file | ||
func CloudfrontListFn(sdkConfig aws.Config) { | ||
// Create cloudfront service client | ||
client := cloudfront.NewFromConfig(sdkConfig) | ||
|
||
result, err := client.ListDistributions(context.TODO(), &cloudfront.ListDistributionsInput{}) | ||
if err != nil { | ||
log.Printf("Couldn't list distribution. Here's why: %v\n", err) | ||
} | ||
|
||
const ( | ||
path = "/cloudfront/distributions.json" | ||
) | ||
|
||
output := CloudfrontList{ | ||
Distributions: result.DistributionList.Items, | ||
} | ||
|
||
filepath := parentpath + sdkConfig.Region + path | ||
|
||
err = utils.WriteJSONToFile(filepath, output) | ||
if err != nil { | ||
fmt.Println("Error writing cloudfront distribution lists") | ||
} | ||
|
||
} |
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