2013-05-28 8 views
5

Cloudformation komut dosyasına bir dosya almaya çalışıyorum. Dosyayı herkesin kullanımına sunacak olursam iyi çalışır. Dosya özelse, cfn komut dosyası başarısız olur, ancak/var/log/dosyasında 404 hatası bulunur. Dosyayı wget yoluyla almaya çalışmak uygun 403 hatasıyla sonuçlanır.Korumalı S3 dosyalarına CFN komut dosyasında nasıl erişebilirim?

S3'ten özel dosyaları nasıl alabilirim?

Dosyam fıkra gibi görünür:

{ 
    "Statement": [ 
    { 
     "Effect": "Allow", 
     "Action": [ 
     "s3:Get*", 
     "s3:List*" 
     ], 
     "Resource": "*" 
    } 
    ] 
} 

cevap

5

çözüm şudur:

"Parameters" : { 
    "BucketRole" : { 
    "Description" : "S3 role for access to bucket", 
    "Type" : "String", 
    "Default" : "S3Access", 
    "ConstraintDescription" : "Must be a valid IAM Role" 
    } 
} 

    "AWS::CloudFormation::Authentication": { 
     "default" : { 
     "type": "s3", 
     "buckets": [ "myConfigBucket" ], 
     "roleName": { "Ref" : "BucketRole" } 
     } 
    }, 

Benim IAM Rolü benziyor:

"files" : { 
     "/etc/httpd/conf/httpd.conf" : { 
     "source" : "https://s3.amazonaws.com/myConfigBucket/httpd.conf" 
     } 
    }, 

Ben bir kimlik doğrulama şartı ve uygun parametreyi eklendi Örnek oluşturma için bir IamInstanceProfile özelliği ekleyin:

"Parameters" : { 
    ... 
    "RoleName" : { 
     "Description" : "IAM Role for access to S3", 
     "Type" : "String", 
     "Default" : "DefaultRoleName", 
     "ConstraintDescription" : "Must be a valid IAM Role" 
    } 
    }, 

    "Resources" : { 
    "InstanceName" : { 
     "Type" : "AWS::EC2::Instance", 
     "Properties" : { 
     "ImageId"    : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "64"] }, 
     "InstanceType"  : { "Ref" : "InstanceType" }, 
     "SecurityGroups"  : [ {"Ref" : "SecurityGroup"} ], 
     "IamInstanceProfile" : { "Ref" : "RoleName" }, 
     "KeyName"    : { "Ref" : "KeyName" } 
     } 
    }, 
    ... 
İlgili konular