private async Task CreateCloudFrontBucket(string bucketName)
{
using (
var client = new AmazonS3Client(cfConfigurationProvider.AccessKey, cfConfigurationProvider.SecretKey,
cfConfigurationProvider.RegionEndpoint))
{
await client.PutBucketAsync(bucketName);
await
client.PutCORSConfigurationAsync(bucketName,
new CORSConfiguration
{
Rules =
{
new CORSRule
{
AllowedHeaders = {"Authorization"},
AllowedMethods = {"GET"},
AllowedOrigins = {"*"},
MaxAgeSeconds = 3000
}
}
});
var policy = new BucketPolicy
{
Version = "2012-10-17",
Statement =
new Statement
{
Sid = "AddPerm",
Effect = "Allow",
Principal = "*",
Action = "s3:GetObject",
Resource = $"arn:aws:s3:::{bucketName}/*"
}
};
await client.PutBucketPolicyAsync(bucketName, JsonConvert.SerializeObject(policy));
}
}