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

feat(datasource/aws-machine-image): Add profile and region configuration support #24086

Merged
merged 15 commits into from Aug 29, 2023
Merged

feat(datasource/aws-machine-image): Add profile and region configuration support #24086

merged 15 commits into from Aug 29, 2023

Conversation

reegnz
Copy link
Contributor

@reegnz reegnz commented Aug 25, 2023

The PR adds region support as well as profile support in case the user wants to utilize the shared config file to switch between configurations.

Changes

The aws-machine-image datasource can optionally handed region and aws-profile configuration through the amiFilter json array.

Context

This is an attempt at fixing #14421.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

Also leave the option open to for additional aws configuration
parameters by parsing a serialized json dictionary.
@CLAassistant
Copy link

CLAassistant commented Aug 25, 2023

CLA assistant check
All committers have signed the CLA.

@reegnz
Copy link
Contributor Author

reegnz commented Aug 25, 2023

Example config used for testing:

config.js

module.exports = {
  platform: "github",
  endpoint: "https://github.example.com/api/v3",
  token: "xxxx",
  repositories: ["reegnz/renovate-test"],
  regexManagers: [
    {
      customType: "regex",
      fileMatch: ['.*\.tfvars$'],
      matchStrings: [
        '.*amiFilter=(?<packageName>.*?)\n(.*currentImageName=(?<currentDigest>.*?)\n)?(.*\n)?.*?(?<depName>[a-zA-Z0-9-_:]*)[ ]*?[:|=][ ]*?["|\']?(?<currentValue>ami-[a-z0-9]{17})["|\']?.*',
      ],
      datasourceTemplate: 'aws-machine-image',
      versioningTemplate: 'aws-machine-image',
    },
  ],
  enabledManagers: ["regex"],
  prHourlyLimit: 0,
  prConcurrentLimit: 0,
}

terraform.tfvars:

# amiFilter=[{"Name":"owner-id","Values":["sanitized"]},{"Name":"name","Values":["sanitized"]},{"profile":"test","region":"us-west-2"}]
# currentImageName=none
us_image_id = "ami-sanitized"

@reegnz reegnz changed the title Add region configuration to aws-machine-image Add profile and region configuration support to aws-machine-image Aug 28, 2023
@reegnz reegnz marked this pull request as ready for review August 28, 2023 11:12
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

needs tests

lib/modules/datasource/aws-machine-image/index.ts Outdated Show resolved Hide resolved
lib/modules/datasource/aws-machine-image/index.ts Outdated Show resolved Hide resolved
* move types to separate types.ts
* change reduce to for..of loop
* run prettier to fix formatting issues
@reegnz
Copy link
Contributor Author

reegnz commented Aug 28, 2023

@viceice Not sure how to test for EC2 client configuration, the existing tests are all mocking the client.

@reegnz reegnz requested a review from viceice August 28, 2023 13:03
@viceice viceice changed the title Add profile and region configuration support to aws-machine-image feat(datasource/aws-machine-image): Add profile and region configuration support Aug 28, 2023
@reegnz
Copy link
Contributor Author

reegnz commented Aug 28, 2023

Going to write some jest tests to test the loadConfig function.

@reegnz
Copy link
Contributor Author

reegnz commented Aug 28, 2023

@viceice let me know what else should be done to move this along. Thanks for having looked at it!

@reegnz reegnz requested a review from viceice August 28, 2023 14:10
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

pnpm lockfile is broken, needs fix

@reegnz
Copy link
Contributor Author

reegnz commented Aug 28, 2023

That's very curious, might have broken it with some change. Pushed a fixed one.

@reegnz reegnz requested a review from viceice August 28, 2023 16:14
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

lint issues 😉

@reegnz
Copy link
Contributor Author

reegnz commented Aug 28, 2023

ah, feel like such a noob! 😮‍💨
Thanks for your patience. Will fix in a sec.

@reegnz reegnz requested a review from viceice August 28, 2023 17:32
@rarkins rarkins added this pull request to the merge queue Aug 29, 2023
Merged via the queue into renovatebot:main with commit 5557ef2 Aug 29, 2023
36 checks passed
@reegnz reegnz deleted the aws_region_config branch August 29, 2023 11:24
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 36.69.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 29, 2023
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.

Support for regions in AWS Resources (aws-machine-image)
6 participants