This section looks at how to use PowerShell to create CloudFront distributions inside AWS. CloudFront is an AWS-provided CDN service that allows you to create a distribution point that points to S3 or Web server, where DNS is automatically resolved to the nearest edge server for optimal access speed.
The specific image interface operation can refer to
http://beanxyz.blog.51cto.com/5570417/1532813
Let's see how PowerShell operates.
First you need to have a S3 bucket (previously created), and then I upload a picture to do the test, remember to set the access rights of the picture to public readable
Write-s3object-bucketname yuanpicture-key "1.jpg"-file "C:\Users\yli\OneDrive\Pictures\2010-09-28 001\1.jpg" Set-s3acl-bucketname yuanpicture-key "1.jpg"-publicreadonlyget-s3object-bucketname yuanpicture-key 1.jpg
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/84/25/wKioL1eHBW3RFbv7AAC6vhzL2-o911.png "title=" 3.PNG " Style= "Float:none;" alt= "Wkiol1ehbw3rfbv7aac6vhzl2-o911.png"/>
Direct access look no problem.
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/84/25/wKioL1eHBXujnAR-ABTQe-EIC6o391.png "title=" 4.PNG " Style= "Float:none;" alt= "Wkiol1ehbxujnar-abtqe-eic6o391.png"/>
Next we need to set a CloudFront distribution point to point to this S3 Bucket
Set origin point to S3 Bucket, set to Global, I also set an alias test.beanxyz.com because the domain he automatically generated is too long.
$origin = new-object amazon.cloudfront.model.origin$origin. Domainname= "yuanpicture.s3.amazonaws.com" $origin. id= "S3-yuanpicture" $origin. S3originconfig = new-object amazon.cloudfront.model.s3originconfig$origin. s3originconfig.originaccessidentity = "" new-cfdistribution -DistributionConfig_Enabled $true ' -distributionconfig_ comment "Test distribution" -Origins_Item $origin ' -Origins_Quantity 1 ' -distributionconfig_callerreference client1 ' - defaultcachebehavior_targetoriginid $origin. id ' -ForwardedValues_QueryString $true ' -Cookies_Forward all '      &NBsp;-whitelistednames_quantity 0 ' -trustedsigners_enabled $ false ' -TrustedSigners_Quantity 0 ' -DefaultCacheBehavior_ViewerProtocolPolicy allow-all ' -DefaultCacheBehavior_MinTTL 1000 ' -distributionconfig_ priceclass "Priceclass_all" ' -cachebehaviors_quantity 0 ' -Aliases_Quantity 1 ' -aliases_item "Test.beanxyz.com"
After the command has been executed, it is created and can be used in about 15 minutes.
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/84/25/wKiom1eHBWfyxdcSAAA0x-_PLbY218.png "style=" float: none; "title=" 1.PNG "alt=" Wkiom1ehbwfyxdcsaaa0x-_plby218.png "/>
At the same time, on my GoDaddy DNS I added an alias to my CloudFront domain name
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/84/25/wKioL1eHBWqDdl3jAABcWXWLePM208.png "style=" float: none; "title=" 2.PNG "alt=" Wkiol1ehbwqddl3jaabcwxwlepm208.png "/>
After 5 minutes of waiting, check DNS has been able to successfully resolve the
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/84/25/wKiom1eHCC-yzRu6AAA8jszRr8k985.png "style=" float: none; "title=" 5.PNG "alt=" Wkiom1ehcc-yzru6aaa8jszrr8k985.png "/>
Visit to see Success!
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/84/25/wKiom1eHCEKw9c_yAB5SjkAQejw434.png "style=" float: none; "title=" 6.PNG "alt=" Wkiom1ehcekw9c_yab5sjkaqejw434.png "/>650) this.width=650; src= http://s4.51cto.com/ Wyfs02/m01/84/25/wkiol1ehcmadps5aab5sjkaqejw001.png "title=" 6.PNG "alt=" Wkiol1ehcmadps5aab5sjkaqejw001.png "/>
This article is from the "Mapo Tofu" blog, please be sure to keep this source http://beanxyz.blog.51cto.com/5570417/1826315
Powershell AWS Automation Management (8)-CloudFront