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

Support auxiliary files in terraform deploy spec #272

Merged
merged 5 commits into from
Feb 9, 2022

Conversation

endorama
Copy link
Member

@endorama endorama commented Feb 9, 2022

What does this PR do?

  • add support for Terraform dependency lock file
  • add support for Terraform template files
  • add support for JSON files

Why is it important?

  • Terraform suggest to add it's dependency lock file to VCS, as it helps with reproducible installations
  • Terraform support template files, with .tftpl suggested extension
  • JSON files may be used for ausiliary content required by Terraform code.

Further discussion available in #269.

Checklist

Related issues

@endorama endorama requested a review from a team as a code owner February 9, 2022 10:04
@endorama endorama self-assigned this Feb 9, 2022
@endorama endorama requested a review from mtojek February 9, 2022 10:04
@endorama endorama force-pushed the 269-terraform-improvements branch from 611ac47 to 0c75cd1 Compare February 9, 2022 10:05
@endorama
Copy link
Member Author

endorama commented Feb 9, 2022

@mtojek I have a question about the changelog. The file header says

[...]
## Newer entries go at the bottom.
[...]

but it seems the opposite is true? Am I expected to append to v1.4.1 as is still unreleased or create a new version?

@elasticmachine
Copy link

elasticmachine commented Feb 9, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-02-09T12:29:55.398+0000

  • Duration: 6 min 4 sec

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@endorama endorama force-pushed the 269-terraform-improvements branch from dc3ecfd to 04f26f8 Compare February 9, 2022 11:19
@jsoriano
Copy link
Member

jsoriano commented Feb 9, 2022

but it seems the opposite is true? Am I expected to append to v1.4.1 as is still unreleased or create a new version?

Put it at the bottom of the 1.4.1 section, yes :)

@@ -10,6 +10,9 @@
- description: Prepare for next version
type: enhancement
link: https://github.com/elastic/package-spec/pull/265
- description: Support ausiliary files in terraform deploy spec
type: enhancement
link: https://github.com/elastic/package-spec/pull/272
Copy link
Member

Choose a reason for hiding this comment

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

👍

@endorama
Copy link
Member Author

endorama commented Feb 9, 2022

I added a deploy_terraform test package, but I'm not sure is being used 🤔 given that I also added the same files to package good, should I remove it?

@jsoriano
Copy link
Member

jsoriano commented Feb 9, 2022

I added a deploy_terraform test package, but I'm not sure is being used thinking given that I also added the same files to package good, should I remove it?

Test packages are used in code/go/pkg/validator/validator_test.go, you will need to add the package there.

@endorama endorama force-pushed the 269-terraform-improvements branch from 4b38af4 to dc0c152 Compare February 9, 2022 11:36
jsoriano
jsoriano previously approved these changes Feb 9, 2022
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

Some nitpicking, but LGTM in general.

@@ -0,0 +1,3 @@
version: '2.3'
services:
hello_world:
Copy link
Member

Choose a reason for hiding this comment

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

Nit. Is this file needed here? I guess it doesn't do any harm though.

Copy link
Member Author

Choose a reason for hiding this comment

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

leftover from copying over the deploy_docker module, thank you for catching this.

- FOO=${BAR:-default-value}
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated changes?

Copy link
Member Author

Choose a reason for hiding this comment

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

No but given the file is not required I'll remove it

@@ -10,6 +10,9 @@
- description: Prepare for next version
type: enhancement
link: https://github.com/elastic/package-spec/pull/265
- description: Support ausiliary files in terraform deploy spec
Copy link
Member

Choose a reason for hiding this comment

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

Nit. Should it be "auxiliary"?

Suggested change
- description: Support ausiliary files in terraform deploy spec
- description: Support auxiliary files in terraform deploy spec

pattern: '^*.json$'
type: file
contentMediaType: "application/json"
required: false
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we end-up needing additionalContents: false if we find scenarios that would need arbitrary files. But we can reduce restrictions in the future if we find these cases.

- description: Terraform dependency lock file
pattern: ".terraform.lock.hcl"
type: file
required: true
Copy link
Member

@jsoriano jsoriano Feb 9, 2022

Choose a reason for hiding this comment

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

Btw, this may be breaking for current packages. At least we will need to add this file to the AWS package when updating the spec in the integrations repo.
https://github.com/elastic/integrations/tree/8e600daead4b89e97271e4976b984722c8db7c74/packages/aws/data_stream/ec2_metrics/_dev/deploy/tf

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice find, actually I don't want to introduce a breaking change here. Do we have a process here? I will make this not required, but I think it make sense to have it everywhere. Is there a way to notify users of this change? For example outputting a message: "this field is going to default to true from version x.y.z"

Copy link
Member

@jsoriano jsoriano Feb 9, 2022

Choose a reason for hiding this comment

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

Maybe we can add this as optional by now, and after some time make it required. At the moment I think that only the AWS package uses it, so not many users affected :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, let's mark it optional for now.

@endorama endorama changed the title Support ausiliary files in terraform deploy spec Support auxiliary files in terraform deploy spec Feb 9, 2022
I would have liked to set this file as required, but it would introduce
a breaking change.

So I added a note to update this requirement in the future.
Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

LGTM

@jsoriano jsoriano merged commit 5462c12 into elastic:main Feb 9, 2022
@endorama endorama deleted the 269-terraform-improvements branch February 9, 2022 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Change Proposal] Support Terraform related files in deploy/tf
4 participants