Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi,

I'm using Amazon S3 for cloud storage.
I want to create a signed url from Amazon .Net SDK (AWSSDK)
But I couldn't do it. I'm having problem on creating distribution.

Here is my code;

C#
Origin origin = new Origin();
origin.DomainName = bucketName + ".s3.amazonaws.com";
origin.OriginPath = folder;
origin.Id = bucketName;

DistributionConfig distributionConfig = new DistributionConfig();
var origins = new Origins();
origins.Items.Add(origin);
distributionConfig.Origins = origins;
distributionConfig.Origins.Quantity = 1;
DefaultCacheBehavior cacheBehavior = new DefaultCacheBehavior();
TrustedSigners trustedSigners = new TrustedSigners();
trustedSigners.Quantity = 0;
trustedSigners.Enabled = false;
cacheBehavior.TrustedSigners = trustedSigners;
cacheBehavior.MinTTL = 0;
ViewerProtocolPolicy viewverPolicy = new ViewerProtocolPolicy("allow-all");
cacheBehavior.ViewerProtocolPolicy = viewverPolicy;
ForwardedValues forwardedValues = new ForwardedValues();
forwardedValues.QueryString = true;
CookiePreference cookiePreference = new CookiePreference();
forwardedValues.Cookies = cookiePreference;
ItemSelection itemSelection = new ItemSelection("all");
forwardedValues.Cookies.Forward = itemSelection;
cacheBehavior.ForwardedValues = forwardedValues;
cacheBehavior.TargetOriginId = "";
distributionConfig.DefaultCacheBehavior = cacheBehavior;
distributionConfig.Enabled = true;
distributionConfig.CallerReference = bucketName;
distributionConfig.Comment = "";

CreateDistributionRequest createDistributionRequest = new CreateDistributionRequest(distributionConfig);
            
var resp = cloudFrontClient.CreateDistribution(createDistributionRequest);


It returns this error:
An unhandled exception of type 'Amazon.CloudFront.Model.NoSuchOriginException' occurred in AWSSDK.dll

Additional information: One or more of your origins do not exist.


But actually bucketName + ".s3.amazonaws.com" exists..

What do you think I'm doing wrong or can you guide for correct sample.
It's hard to find a sample for this process on the net.
Posted
Comments
ZurdoDev 29-Jan-16 10:43am    
I'd suggest you ask Amazon support first. You'll likely get an answer much faster that way.
kubibay 1-Feb-16 2:40am    
I did, thanks for feedback..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900