Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Making CIDR Blocks Configurable #85

Merged
merged 12 commits into from
Feb 1, 2021
Merged

Conversation

MatthiasScholz
Copy link
Contributor

@MatthiasScholz MatthiasScholz commented Jan 3, 2021

Solves #84.

Refactoring the terraform configuration to configure:

  • SSH access using CIDR blocks
  • Traffic access using CIDR blocks

Additionally a test is provided testing SSH access for access and deny.
Unfortunately, due to a bug in the terraform CLI test execution, with positive and negative access testing, was not possible using MacOSX operating system and hence only a positive test using the existing example is provided.

MatthiasScholz and others added 5 commits December 29, 2020 22:46
Testing SSH access depending on the CIDR block configuration.

Nevertheless due to a bug in the terraform CLI:
- hashicorp/terraform#17032
test execution is not possible until the bug is solved.
@hashicorp-cla
Copy link

hashicorp-cla commented Jan 3, 2021

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@brikis98 brikis98 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Please see my comment about examples vs prod code.

I think the part of the PR that's useful are the changes to the modules folder to make the outbound CIDR blocks configurable, and to not create inbound SSH SG rules if that list is empty. Everything else seems to affect examples only and is intentionally left open.

examples/nomad-consul-separate-cluster/main.tf Outdated Show resolved Hide resolved
modules/nomad-cluster/main.tf Outdated Show resolved Hide resolved
modules/nomad-cluster/variables.tf Outdated Show resolved Hide resolved
test/README.md Show resolved Hide resolved
MatthiasScholz and others added 2 commits January 7, 2021 19:56
Co-authored-by: Yevgeniy Brikman <brikis98@users.noreply.github.com>
Co-authored-by: Yevgeniy Brikman <brikis98@users.noreply.github.com>
Reverting the changes made to allow the configuration of the CIDR blocks
for SSH and outbound traffic for the examples.

Additionally, since the examples now lacking the flexibility, the
SSH test now only checks if access is possible.
Copy link
Collaborator

@brikis98 brikis98 left a comment

Choose a reason for hiding this comment

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

OK, one more NIT, and I can kick off tests!

aws.DeleteAmi(t, awsRegion, amiId)
})

test_structure.RunTestStage(t, "setup_ami", func() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you run go fmt on this code? The indentation looks off.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see - thanks for pointing this out. It should be fixed now.

MatthiasScholzTW added a commit to MatthiasScholz/cos that referenced this pull request Jan 17, 2021
MatthiasScholzTW added a commit to MatthiasScholz/cos that referenced this pull request Jan 17, 2021
MatthiasScholz added a commit to MatthiasScholz/cos that referenced this pull request Jan 17, 2021
* 📌 version updates for all major components | #85

Covering the following dependencies:
- nomad: 1.0.2
- consul: 1.9.1
- fabio
- terraform modules
  - terraform-aws-consul module version 0.8.2
- packer definition
- terraform: 0.14.4

* ♻️ Migrate from SSH to SSM and restructuring | #83

- Remove SSH dependency
- Using AWS System Manager Session Manager instead of SSH access.

* ✨ AMI testing during creation

- Checking the AMI during the packer build step using goss.

* ✨ restart nomad service on instance, solves #62

* 👷 added linting

* 🐛 fixing aws provider version due to autoscaling issue

An unsolved regression in the terraform-provider-aws
(  hashicorp/terraform-provider-aws#14085 )
prevents the creation of autoscaling groups using terraform.

* 💩 using fork to unblock waiting for PR | #85

Waiting for PR to be merge:
hashicorp/terraform-aws-nomad#85

Co-authored-by: Matthias Scholz <matthias.scholz@gmail.com>
Co-authored-by: Matthias Scholz <matthias.scholz@thoughtworks.com>
Copy link
Collaborator

@brikis98 brikis98 left a comment

Choose a reason for hiding this comment

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

Thanks! I'll kick off tests now.

@brikis98
Copy link
Collaborator

Looks like you still need a go fmt:

[INFO] Initializing environment for https://github.com/gruntwork-io/pre-commit.
Terraform fmt............................................................Passed
gofmt....................................................................Failed
- hook id: gofmt
- files were modified by this hook

test/nomad_helpers.go
test/nomad_helpers.go

@brikis98
Copy link
Collaborator

Running tests once more!

@brikis98
Copy link
Collaborator

Looks like you're missing some imports in the test code:

go: downloading github.com/russross/blackfriday/v2 v2.0.1
go: downloading github.com/shurcooL/sanitized_anchor_name v1.0.0
# github.com/gruntwork-io/terraform-aws-nomad/test [github.com/gruntwork-io/terraform-aws-nomad/test.test]
./nomad_helpers.go:57:17: undefined: test_structure
./nomad_helpers.go:59:8: undefined: test_structure
./nomad_helpers.go:60:23: undefined: test_structure
./nomad_helpers.go:63:12: undefined: test_structure
./nomad_helpers.go:64:16: undefined: test_structure
./nomad_helpers.go:68:2: undefined: test_structure
./nomad_helpers.go:70:3: undefined: test_structure
./nomad_helpers.go:73:3: undefined: test_structure
./nomad_helpers.go:76:3: undefined: test_structure
./nomad_helpers.go:79:2: undefined: test_structure
./nomad_helpers.go:79:2: too many errors
FAIL	github.com/gruntwork-io/terraform-aws-nomad/test [build failed]

Did you ever run or at least compile this code?

Add support for terraform >= 0.14.3 using a wrapper function
to bypass terratest limitation:
- gruntwork-io/terratest#766

Adding missing SSH key pair to make SSH test work.
@brikis98
Copy link
Collaborator

Running tests again!

@MatthiasScholz
Copy link
Contributor Author

Since I ran into the issue with an incompatible terraform / terratest combination, should I update the referenced terratest version as well and remove the workaround - or should the terratest update better be handled with a separate PR?

@brikis98
Copy link
Collaborator

Since I ran into the issue with an incompatible terraform / terratest combination, should I update the referenced terratest version as well and remove the workaround - or should the terratest update better be handled with a separate PR?

Separate PR would be better. Thank you!

@MatthiasScholz
Copy link
Contributor Author

I saw the last test run failed due to "No cluster leader" error reported and the cluster not being able to elect a leader even after some retries. It does not seem to be related to the PR itself. What do you think?

Trying to reproduce the issue running the test again using my AWS account was not successful. It might be a timing issue.

Is there anything I could check further?

@brikis98
Copy link
Collaborator

brikis98 commented Feb 1, 2021

It's hard to tell! There is an intermittent test failure hiding in this repo, as most nightly tests pass, but occasionally, we get a failure. I'm going to re-run the tests to see what happens.

@brikis98
Copy link
Collaborator

brikis98 commented Feb 1, 2021

Yup, looks like an intermittent issue. OK, on another re-ran, tests passed, so it can't be anything related to this PR, as a bug in this PR would probably result in failures consistently. Thanks for the PR/patience. Merging now!

@brikis98 brikis98 merged commit bf3ee5f into hashicorp:master Feb 1, 2021
@brikis98
Copy link
Collaborator

brikis98 commented Feb 1, 2021

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

Successfully merging this pull request may close these issues.

None yet

4 participants