Skip to content

Commit

Permalink
working policy assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
m-s-austin committed May 13, 2015
1 parent 3ab901d commit 0975a70
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions builtin/providers/aws/resource_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ func resourceAwsS3BucketCreate(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error creating S3 bucket: %s", err)
}

policy := d.Get("policy").(string)
if policy != "" {
log.Printf("[DEBUG] S3 bucket optional policy was specified: %s", policy)
_, err := s3conn.PutBucketPolicy(
&s3.PutBucketPolicyInput{
Bucket: aws.String(bucket),
Policy: aws.String(policy),
})
if err != nil {
return fmt.Errorf("Error adding policy to S3 bucket: %s", err)
}
}

// Assign the bucket name as the resource ID
d.SetId(bucket)

Expand Down

0 comments on commit 0975a70

Please sign in to comment.