Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2544 terraform s3 policy #1

Closed
wants to merge 12 commits into from
Closed

Conversation

m-s-austin
Copy link

This code adds a new provider to terraform that allows you to add a Policy to an s3 bucket like this:

resource "aws_s3_bucket_policy" "test_policy" {
name = "Bucket Test Policy"
bucket = "${aws_s3_bucket.b.id}"
policy = <<EOF
{
"Id": "Policy1431447664360",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1431447659873",
"Action": [
"s3:GetObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::my_tf_test_bucket/",
"Principal": ""
}
]
}
EOF
}

@chimmelb
Copy link

+1
Admittedly I don't know Go. The code looks clean enough.

@tehnorm
Copy link

tehnorm commented May 15, 2015

Did we figure out the unit testing process? Would love to see working unit tests with this before we merge it down.

@m-s-austin
Copy link
Author

@tehnorm They have "acceptance tests" but not "unit tests" the acceptance tests still run, I can work on figuring out how to write more. They appear to be more of an integration type test than a unit test, in that they actually create / destroy live resources on the services.

It's going to take at least a day or two of research to understand how to write my own. However, I might be able to get some feedback from hashicorp. that might help.

s3conn := meta.(*AWSClient).s3conn
bucket := d.Get("bucket").(string)
policy := d.Get("policy").(string)
name := d.Get("name").(string)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I also do not know Go, but would it be possible to give these variables some more descriptive names? What is 'd', for instance?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's basically their standard:
https://godoc.org/github.com/hashicorp/terraform/helper/schema#pkg-index

d *ResourceData technically if I was going strictly by their practices I probably should have stuck with m for meta.

I agree it's not very descriptive.

@m-s-austin
Copy link
Author

I will probably be closing this in favor of
hashicorp#1992

I have been testing it and it seems to have all the same functionality as well as already having tests.

@m-s-austin
Copy link
Author

1992 has already been merged into master on hashicorp.

@m-s-austin m-s-austin closed this May 18, 2015
m-s-austin pushed a commit that referenced this pull request Oct 13, 2015
Docs for aws_s3_bucket content argument
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants