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

[terraform/upgrade-modules] Update all module sources to latest version #95

Merged
merged 6 commits into from Aug 24, 2018

Conversation

osterman
Copy link
Member

@osterman osterman commented Aug 23, 2018

what

  • Add new target to upgrade all module sources

why

  • Keep modules up to date

demo

Processing ./test/test.tf...
[SKIPPED]: ../
Processing ./test/cloud-provider.tf...
Processing ./examples/wordpress/main.tf...
[SKIPPED]: ../../
Processing ./main.tf...
[GITHUB]: git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.3.7
 - Latest: 0.3.7 -> 0.4.1
 - Source: git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.4.1
[GITHUB]: git::https://github.com/cloudposse/terraform-aws-log-storage.git?ref=tags/0.2.2
 - Current: 0.2.2
[GITHUB]: git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.3.7
 - Latest: 0.3.7 -> 0.4.1
 - Source: git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.4.1
[GITHUB]: git::https://github.com/cloudposse/terraform-aws-route53-alias.git?ref=tags/0.2.5
 - Current: 0.2.5
Processing ./variables.tf...
Processing ./outputs.tf...

references

@osterman osterman changed the title Add script to update all terraform module sources [terraform/upgrade-modules] Update all module sources to latest version Aug 23, 2018
Copy link
Contributor

@sarkis sarkis left a comment

Choose a reason for hiding this comment

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

LGTM - however, this required json2hcl and jq.. should there be warnings emitted if they are not present maybe at the top of the upgrade_terraform_modules.sh for now?

@osterman osterman added the do not merge Do not merge this PR, doing so would cause problems label Aug 23, 2018
@osterman
Copy link
Member Author

@sarkis yea good point

function github_latest_release() {
local org=$1
local repo=$2
local ref=$(curl -sSL https://api.github.com/repos/$org/$repo/releases/latest | jq .tag_name -r)
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

GitHub rate-limits unauthenticated calls to their api endpoint by source IP.

https://developer.github.com/changes/2012-10-14-rate-limit-changes/

I've found this kind of query works fine locally, but fails sporadically from CI. The typical workaround seems to be to create a bot user with zero access to anything, generate an access token, and then use basic auth in the curl command....

curl -sSL https://api.github.com/repos/$org/$repo/releases/latest?access_token=<the access token>

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right. I was just being lazy =)

I've added support for the tokens. Decided to use a header since that is less likely to show up in access logs. https://gist.github.com/caspyin/2288960#oauth

@osterman osterman requested review from goruha and sarkis August 23, 2018 20:45
@osterman osterman removed the do not merge Do not merge this PR, doing so would cause problems label Aug 23, 2018
@tamsky
Copy link
Contributor

tamsky commented Aug 23, 2018

Very entertaining usage of json2hcl | jq -- glad to see it being used for good.

@osterman osterman merged commit e43a67c into master Aug 24, 2018
@osterman osterman deleted the upgrade-tf-sources branch August 24, 2018 18:34
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.

None yet

6 participants