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

provider/aws: Add FlowLog resource #2384

Merged
merged 11 commits into from
Jun 23, 2015
Merged

provider/aws: Add FlowLog resource #2384

merged 11 commits into from
Jun 23, 2015

Conversation

catsby
Copy link
Contributor

@catsby catsby commented Jun 17, 2015

This is a proposal config/work for adding a FlowLog resource.

Syntax:

resource "aws_flow_log" "test_flow_log" {
  log_group_name = "tf-test-log-group"
  iam_role_arn = "arn:aws:iam::470663696735:role/tf-test-cloud"
  vpc_id = "${aws_vpc.default.id}"
  traffic_type = "ALL"
}

API Docs:

A FlowLog can be attached to either a VPC, Subnet, or ENI. The API call is the same, you just supply the resource id and type. Here I propose separate vpc_id, subnet_id, and eni_id syntax, to avoid a user having to specify both a resource id and the type.

Additionally, the API supports creating multiple flows in a single call, but this creates multiple FlowLogs, , so our implementation will be 1:1.

Remaining:

  • Docs
  • Implementation
  • Acceptance tests

@@ -85,12 +85,13 @@ func Provider() terraform.ResourceProvider {
ResourcesMap: map[string]*schema.Resource{
"aws_app_cookie_stickiness_policy": resourceAwsAppCookieStickinessPolicy(),
"aws_autoscaling_group": resourceAwsAutoscalingGroup(),
"aws_flow_log": resourceAwsFlowLog(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Alphabetize por favor! 🔠 😁

@catsby
Copy link
Contributor Author

catsby commented Jun 17, 2015

cc @radeksimko since I know he has at least looked into Flow Logs

return nil
}

func flowLogStateRefreshFunc(conn *ec2.EC2, sn string) resource.StateRefreshFunc {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this guy is unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😱

@phinze
Copy link
Contributor

phinze commented Jun 17, 2015

Review complete - Looking great overall!

"testing"

"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/aws-sdk-go/aws"
Copy link
Member

Choose a reason for hiding this comment

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

why this import?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wow, great catch! My editor must have auto populated that 😱

Fixed in 0bf127a

@catsby catsby changed the title Proposal provider/aws: Docs for FlowLog resource provider/aws: Add FlowLog resource Jun 18, 2015
@catsby
Copy link
Contributor Author

catsby commented Jun 18, 2015

@phinze cleaned up, sorry for the sloppy 😐

}

log.Printf(
"[DEBUG] Flow Log Create configuration: %s", awsutil.StringValue(opts))
Copy link
Member

Choose a reason for hiding this comment

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

Nice! 👍 Isn't this basically addressing #2179 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

awsutil.StringValue does, yes, but to close #2179 we need to use it in All The Places™

@radeksimko
Copy link
Member

@catsby It looks ok, just one question here:
What is the benefit behind saving flow_log_status and deliver_log_status?

I thought that change in the state should be changed because user/human has done something in order to change the state. My understanding is that these two things will change without user's interaction over time and so far I don't see how would any other Terraform resource react on that.

@radeksimko
Copy link
Member

I reckon this can be fixed later on after merging, but just FYI regarding example in docs:

http://docs.aws.amazon.com/cli/latest/reference/ec2/create-flow-logs.html

In your request, you must also specify an IAM role that has permission to publish logs to CloudWatch Logs.

We're not defining that permission anywhere.

* master:
  Update CHANGELOG.md
  Update CHANGELOG.md
  Added affinity group resource.
  update link to actually work
  provider/azure: Fix SQL client name to match upstream
  add warning message to explain scenario of conflicting rules
  typo
  remove debugging
  Update CHANGELOG.md
  provider/aws: Add docs for autoscaling_policy + cloudwatch_metric_alarm
  provider/aws: Add autoscaling_policy
  provider/aws: Add cloudwatch_metric_alarm
  rename method, update docs
  clean up some conflicts with
  clean up old, incompatible test
  update tests with another example
  update test
  remove meta usage, stub test
  fix existing tests
  Consider security groups with source security groups when hashing
@catsby
Copy link
Contributor Author

catsby commented Jun 22, 2015

@radeksimko Thanks for reviewing

What is the benefit behind saving flow_log_status and deliver_log_status?

I thought it would be useful, but in hindsight agree, so I removed them in 87c7f63

We're not defining that permission anywhere.

I updated the documentation to include the needed IAM things to get Flow Logs working, and verified they work. The Logs must Flow

@phinze
Copy link
Contributor

phinze commented Jun 23, 2015

LGTM

catsby added a commit that referenced this pull request Jun 23, 2015
provider/aws: Add FlowLog resource
@catsby catsby merged commit 24c4c55 into master Jun 23, 2015
@catsby catsby deleted the f-aws-flow-logs branch June 23, 2015 20:08
@ghost
Copy link

ghost commented May 2, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators May 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants