-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Initial add of MSK resources #6809
Conversation
Related: #6655 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me, particularly for a first contribution but there's a few things I picked up on in a short review.
aws/resource_aws_msk_cluster.go
Outdated
} | ||
|
||
func resourceAwsMskClusterUpdate(d *schema.ResourceData, meta interface{}) error { | ||
// TODO: Figure out update as API calls not yet implemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the API doesn't provide update calls then you need to ditch this and just use ForceNew
on everything for now. If AWS eventually adds updating a MSK cluster then someone will be able to update this resource to support updates.
As an example, here's the ECS task definition resource before tagging was added (making it no longer just an immutable resource): https://github.com/terraform-providers/terraform-provider-aws/blob/f7c0899ca731c70659eb6b8e40ea520d095ffb1c/aws/resource_aws_ecs_task_definition.go
Delete: resourceAwsMskClusterDelete, | ||
Importer: &schema.ResourceImporter{ | ||
State: schema.ImportStatePassthrough, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're missing a test for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what this actually does or how to test it. Didnt see an example elsewhere in the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomelliff there is only this issue before merging to master?
aws/data_source_aws_mks_cluster.go
Outdated
d.Set("arn", state.arn) | ||
d.Set("status", state.status) | ||
d.Set("creation_timestamp", state.creationTimestamp) | ||
d.Set("encrypt_rest_arn", state.encryptRestArn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've used encrypt_rest_key
in the schema here but set this to encrypt_rest_arn
which is what you're using elsewhere. Personally I find the encryptRestArn
to be slightly confusing without any mention that it's the KMS key ARN and had to check the source to see that that was the case so I'd switch everything over to encrypt_rest_key
or some variant on that.
Also it might help to add an acceptance test for this data source even if you are just exercising the same method as the read on the resource just to catch mistakes in the schema like this.
@tomelliff Thanks for the feedback. As this is my first contribution, I'm still trying to figure out how the whole system works. Your comments are very helpful. I am a little ignorant about how |
The plan will show a +- against the resource to show that it needs to be destroyed and recreated. There is also a (forces new resource) against any changing attributes that cause Terraform to force a rebuild and it's a very common pattern across a wide set of resources so shouldn't come across as a surprise to the user. Of course if you set everything as ForceNew and build it you should be able to see the results for yourself. |
3ba14b5
to
9b21435
Compare
* `broker_count` - (Required) Number of broker nodes you want to create in each Availability Zone. | ||
* `broker_instance_type` - (Required) Instance type for brokers from the m5 family. e.g. kafka.m5.large | ||
* `broker_volume_size` - (Required) The size of the drive in GiBs. | ||
* `broker_security_groups` - (Optional) Security groups to attach to broker nodes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required
Delete: resourceAwsMskClusterDelete, | ||
Importer: &schema.ResourceImporter{ | ||
State: schema.ImportStatePassthrough, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomelliff there is only this issue before merging to master?
👍 this would be a great thing to have. I fully support this endeavor as I have a project coming on line that would be able to leverage this immediately. |
@gavinmbell I agree, we need to find out how we can encourage the final reviews (like from @mrf and @tomelliff) before this becomes a dead PR. I've also tried posting in the IRC room to no avail. |
+1 This is a really great feature. After AWS went live with MSK, I was pretty excited. I'm an SUPER excited to see this get implemented into terraform to make automated deployments work with MSK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jrefi 👋 Thanks for submitting this. Please see the below initial feedback and let us know if you have any questions or do not have time to implement the items.
@@ -159,6 +159,7 @@ type Config struct { | |||
EsEndpoint string | |||
ElbEndpoint string | |||
IamEndpoint string | |||
KafkaEndpoint string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some additional configuration steps required to support customizing service endpoints. We have opted to allow customizing all endpoints (#8096) so this change should be removed from this pull request. 👍
@@ -937,6 +939,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) { | |||
config.ElbEndpoint = endpoints["elb"].(string) | |||
config.EsEndpoint = endpoints["es"].(string) | |||
config.IamEndpoint = endpoints["iam"].(string) | |||
config.KafkaEndpoint = endpoints["kafka"].(string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted above, this change should be removed from this pull request.
}, | ||
"broker_node_group_info": { | ||
Type: schema.TypeString, | ||
Optional: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: true
should be removed/replaced with only Computed: true
for this and all the below attributes since they are not configurable to influence the data source lookup.
Config: config, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckMskClusterExists("aws_msk_cluster.test_cluster", &cluster), | ||
resource.TestCheckResourceAttrSet("data.aws_msk_cluster.test_cluster", "arn"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data source testing should preferably use resource.TestCheckResourceAttrPair()
to ensure values match between the resource and data source, e.g.
resource.TestCheckResourceAttrSet("data.aws_msk_cluster.test_cluster", "arn"), | |
resource.TestCheckResourceAttrPair("data.aws_msk_cluster.test_cluster", "arn", "aws_msk_cluster.test_cluster", "arn"), |
This should be done for all data source attribute checks.
resource "aws_subnet" "test_subnet_a" { | ||
vpc_id = "${aws_vpc.test_vpc.id}" | ||
cidr_block = "10.1.1.0/24" | ||
availability_zone = "us-east-1a" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The acceptance testing framework for the provider runs in us-west-2
by default:
Hardcoded availability zones should instead be replaced with the aws_availability_zones
data source.
--- | ||
layout: "aws" | ||
page_title: "AWS: aws_msk_cluster" | ||
sidebar_current: "docs-aws-resource-msk-cluster" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This documentation page is missing a sidebar link in a new MSK Resources
section of website/aws.erb
|
||
## Attributes Reference | ||
|
||
See the [`aws_msk_cluster` resource](/docs/providers/aws/r/msk_cluster.html) for details on the returned attributes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data source attributes can easily become out of sync with their resource counterpart since they require a separate schema definition and appropriate d.Set()
calls. We prefer to list out the attributes separately.
* `broker_instance_type` - (Required) Instance type for brokers from the m5 family. e.g. kafka.m5.large | ||
* `broker_volume_size` - (Required) The size of the drive in GiBs. | ||
* `broker_security_groups` - (Required) Security groups to attach to broker nodes. | ||
* `encrypt_rest_arn` - (Optional) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This argument is missing documentation.
}, | ||
Timeouts: &schema.ResourceTimeout{ | ||
Create: schema.DefaultTimeout(60 * time.Minute), | ||
Update: schema.DefaultTimeout(120 * time.Minute), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This resource does not implement the Update
function so this should be removed.
* `encrypt_rest_key` - The AWS KMS key used for data encryption. | ||
* `zookeeper_connect` - Connection string for Zookeeper. | ||
* `bootstrap_brokers` - A list of brokers that a client application can use to bootstrap. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation for the customizable timeouts is missing:
## Timeouts | |
`aws_msk_cluster` provides the following [Timeouts](/docs/configuration/resources.html#timeouts) configuration options: | |
* `create` - (Default `60m`) How long to wait for cluster creation. | |
* `delete` - (Default `120m`) How long to wait for cluster deletion. | |
@jrefi If you are low on time/resources, please let me know I would be happy to take a handoff from you and address feedback myself. |
@dthtvwls Thanks. Yeah, actually my organization has decided that MSK is not yet a viable option for us and thus this is no longer a priority. If you don't mind cleaning the PR up, I would greatly appreciate it. |
@dthtvwls a new PR is totally fine (preserving the previous authors commits where possible) 👍 |
@bflad I just left a review. One more question before I make the new PR. Thanks |
move brokers call go fmt
Please see #8357 which now supersedes this request. |
move brokers call go fmt
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Fixes #6653
Changes proposed in this pull request:
aws_msk_cluster
resource to support Managed Streams for Kafka.TODO:
Output from acceptance testing:
Example Resource configuration: