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 key_name_prefix argument to aws_key_pair resource #9993

Merged
merged 10 commits into from
Nov 9, 2016
Merged

provider/aws: Add key_name_prefix argument to aws_key_pair resource #9993

merged 10 commits into from
Nov 9, 2016

Conversation

nicksantamaria
Copy link
Contributor

@nicksantamaria nicksantamaria commented Nov 9, 2016

What does this PR do?

This PR adds a new argument to the aws_key_pair resource called key_name_prefix. This behaves in the same way as name_prefix seen on several other AWS resources.

Any background context you want to provide?

It is worth noting that the current key_name argument will auto-generate an identifier if omitted. This was documented incorrectly which lead me down the path of implementing this (documentation now fixed in #9992).

What are the relevant tickets?

I could not find an existing issue requesting this enhancement.

Checklist

Acceptance test coverage of new behaviour
Implemented - see builtin/providers/aws/resource_aws_key_pair_test.go

$ make testacc TEST=./builtin/providers/aws TESTARGS='-run=testAccCheckAWSKeyPair_namePrefix'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/11/09 23:40:07 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=testAccCheckAWSKeyPair_namePrefix -timeout 120m
PASS
ok  	github.com/nicksantamaria/terraform/builtin/providers/aws	0.019s

Documentation updates
Implemented - see website/source/docs/providers/aws/r/key_pair.html.markdown

Well-formed Code
make fmt does not show any failures.

@nicksantamaria nicksantamaria changed the title Feature/aws key pair name prefix Add key_name_prefix argument to aws_key_pair resource Nov 9, 2016
@nicksantamaria nicksantamaria changed the title Add key_name_prefix argument to aws_key_pair resource provider/aws: Add key_name_prefix argument to aws_key_pair resource Nov 9, 2016
Copy link
Contributor

@stack72 stack72 left a comment

Choose a reason for hiding this comment

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

Hi @nicksantamaria

This is looking good - one question within

It seems like that acceptance tests didn't run here - can you check them again and drop the _key suffix?

P.

value := v.(string)
if len(value) > 100 {
errors = append(errors, fmt.Errorf(
"%q cannot be longer than 100 characters, name is limited to 255", k))
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason why you chose 100 as the max length here?

Copy link
Contributor Author

@nicksantamaria nicksantamaria Nov 9, 2016

Choose a reason for hiding this comment

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

This matches the validation for the name_prefix argument for aws_security_group resource. I have double-checked and the maximum key pair name length is 255 characters.

screen shot 2016-11-10 at 12 30 06 am

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it :)

@stack72 stack72 added enhancement provider/aws waiting-response An issue/pull request is waiting for a response from the community labels Nov 9, 2016
@stack72
Copy link
Contributor

stack72 commented Nov 9, 2016

This LGTM! Thanks for the work on this :)

% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSKeyPair_'                                                               ✭
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/11/09 15:26:41 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSKeyPair_ -timeout 120m
=== RUN   TestAccAWSKeyPair_importBasic
--- PASS: TestAccAWSKeyPair_importBasic (53.48s)
=== RUN   TestAccAWSKeyPair_basic
--- PASS: TestAccAWSKeyPair_basic (30.77s)
=== RUN   TestAccAWSKeyPair_generatedName
--- PASS: TestAccAWSKeyPair_generatedName (22.10s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    106.368s

@stack72 stack72 merged commit 8949419 into hashicorp:master Nov 9, 2016
stack72 pushed a commit that referenced this pull request Nov 9, 2016
…9993)

* Added key_name_prefix to aws_key_pair resource schema.

* Added logic to prefix the aws_key_pair name on create.

* Added aws_key_pair test config for key_name_prefix case.

* Copied test cases from testAccAWSSecurityGroup namespace.

* Modified copied test case to suit aws_key_pair resource.

* Changed required flag to optional on key_name argument for aws_key_pair resource.

* Added documentation for key_name_prefix argument.

* Code style fix.

* Fixed undefined variable error in test.
@nicksantamaria nicksantamaria deleted the feature/aws_key_pair-name_prefix branch November 9, 2016 21:40
gusmat pushed a commit to gusmat/terraform that referenced this pull request Dec 6, 2016
…ashicorp#9993)

* Added key_name_prefix to aws_key_pair resource schema.

* Added logic to prefix the aws_key_pair name on create.

* Added aws_key_pair test config for key_name_prefix case.

* Copied test cases from testAccAWSSecurityGroup namespace.

* Modified copied test case to suit aws_key_pair resource.

* Changed required flag to optional on key_name argument for aws_key_pair resource.

* Added documentation for key_name_prefix argument.

* Code style fix.

* Fixed undefined variable error in test.
@ghost
Copy link

ghost commented Apr 20, 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 Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement provider/aws waiting-response An issue/pull request is waiting for a response from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants