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

aws_elasticache_replication_group #143

Merged

Conversation

Rihoj
Copy link
Contributor

@Rihoj Rihoj commented Jul 19, 2021

fixes #140

Adds rules for aws_elasticcache_replication_group resource

…ests fir aws_elasticache_replication_group # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # Date: Mon Jul 19 15:34:06 2021 -0400 # # On branch aws_elasticache_replication_group # Changes to be committed: # modified: docs/rules/aws_elasticache_cluster_default_parameter_group.md # new file: docs/rules/aws_elasticache_replication_group_default_parameter_group.md # new file: rules/aws_elasticache_replication_group_default_parameter_group.go # new file: rules/aws_elasticache_replication_group_default_parameter_group_test.go # new file: rules/aws_elasticache_replication_group_invalid_type.go # new file: rules/aws_elasticache_replication_group_invalid_type_test.go #
@Rihoj Rihoj changed the title aws_elasticache_replication_group - fixes terraform-linters/tflint-r… aws_elasticache_replication_group Jul 19, 2021
Copy link
Member

@wata727 wata727 left a comment

Choose a reason for hiding this comment

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

Good job!

If you want to add a new rule, you need to register the rule in rules/provider.go and update the docs/rules/README.md. Please refer to #101

Also, You can use the generator to automate the work required to add new rules. See also here:
https://github.com/terraform-linters/tflint-ruleset-aws#add-a-new-rule

Thank you for your contribution :)

return project.ReferenceLink(r.Name())
}

var defaultElastiCacheParameterGroupRegexp = regexp.MustCompile("^default")
Copy link
Member

Choose a reason for hiding this comment

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

The defaultElastiCacheParameterGroupRegexp is already declared in here:

var defaultElastiCacheParameterGroupRegexp = regexp.MustCompile("^default")

Perhaps it's better to declare a variable name for this rule here.

@Rihoj
Copy link
Contributor Author

Rihoj commented Jul 23, 2021

@wata727 I would like to also add in the rules for invalid parameter group, security group, and subnet group. However, I am not sure if I should try to add these into the API folder or not. I tried running go run ./rules/api/generator and received an error about build constraints. When I ran go run ./rules/api/generator/main.go it complained it couldn't find a file.

Are you wanting these rules inside the API folder and if so how would I go about creating these? If not am I good to create them with the same process as the rules I just added.

@wata727
Copy link
Member

wata727 commented Jul 23, 2021

The rules under the rules/api directory are a list of rules that are active only when deep_check is enabled, and if you want to create a rule like aws_elasticache_cluster_invalid_parameter_group, you need to put it under this directory.

These rules are automatically generated from definition files and you need to add a definition file like https://github.com/terraform-linters/tflint-ruleset-aws/blob/ef81b2ce272c396443598c6f37afa60b595f08c6/rules/api/definitions/aws_elasticache_cluster.hcl.

However, this is a bit complicated, so it seems good to get it out of the scope of this PR.

I tried running go run ./rules/api/generator and received an error about build constraints.

Oops, this seems like a bug...

@wata727 wata727 merged commit 2d95a80 into terraform-linters:master Jul 23, 2021
@wata727
Copy link
Member

wata727 commented Jul 23, 2021

👍

@wata727
Copy link
Member

wata727 commented Jul 23, 2021

Oops, this seems like a bug...

Sorry, it is wrong. You can run this generator like the following:

cd rules/api
go run -tags generators ./generator

resourceType: "aws_elasticache_replication_group",
attributeName: "node_type",
nodeTypes: map[string]bool{
"cache.t2.micro": true,
Copy link
Contributor

Choose a reason for hiding this comment

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

This list could probably be shared with the same list here:

Copy link
Contributor

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

aws_elasticache_replication_group same basic rules
3 participants