Terraform: How to install multiple versions of provider plugins? [duplicate] - terraform-provider-azure

This question already has answers here:
Multiple provider versions with Terraform
(2 answers)
Closed 2 years ago.
I am trying to deploy Azure resources through Terraform 0.12 with azurerm provider.
I have AKS module which works fine with azurerm version 2.5.0, but breaks with 2.9.0.
On the other hand Postgresql module works with version 2.9.0 but breaks with 2.5.0
I want to deploy both resources through a single terraform apply.
I tried below configuration but it fails at initialize phase.
provider "azurerm" {
version = "=2.9.0"
}
provider "azurerm" {
alias = "latest"
version = "=2.5.0"
}
$ terraform.exe init
Initializing the backend...
Initializing provider plugins...
- Checking for available provider plugins...
No provider "azurerm" plugins meet the constraint "=2.5.0,=2.9.0".
The version constraint is derived from the "version" argument within the
provider "azurerm" block in configuration. Child modules may also apply
provider version constraints. To view the provider versions requested by each
module in the current configuration, run "terraform providers".
To proceed, the version constraints for this provider must be relaxed by
either adjusting or removing the "version" argument in the provider blocks
throughout the configuration.
Error: no suitable version is available
How to install both provider versions and point AKS module to v2.5.0 and point Postgres module to v2.9.0

Break the code into Modules and add provider section in your module and call the modules differently in your main.tf file.
Example
modules/AKS
provider {
}
modules/DB
provider {
}
Now call your modules differently
main.tf
module "AKS" {
source = "../modules/AKS"
}
module "DB" {
source = "../modules/DB"
}

Related

Serverless Version Upgrade Name resolution errors

I was trying to update the serverless version for my project from 2.72 to 3.x. Hence I started working on the resolution of the deprecations warnings. All are gone except of the following.
Cannot resolve variable at "resources.Resources.ApiGatewayAcessLogsSubscriptionFilter.Properties.DestinationArn": String value consist of variable which resolve with non-string value
The variable inside the serverless.yml is referenced as follow
{self:custom.localEnvironment.logs-destination.${self:provider.region}}
The custom section of the serverless.yml is defined as follow:
custom:
localEnvironment:
logs-destination:
region-x: "**** destination log group"
Environment Information
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 14.20.0
Framework Version: 2.72.3 (local)
Plugin Version: 5.5.4
SDK Version: 4.3.2
Components Version: 3.18.2
Note env says version is 2.72.3 but to enforce the new name resolver I am using the following in the file
variablesResolutionMode: 20210326
I looked for various resources on the serverless forums, didn't find something which match exactly with my situation. Though I have found the following un-answered question
https://forum.serverless.com/t/variables-resolution-errored/16999
P.S. New to the community please feel free to edit the question.

Terraform warning: Warning: "use_microsoft_graph": [DEPRECATED] This field now defaults to `true` and will be removed in v1.3 of Terraform Core

I created a Terraform configuration to create a resource group. This uses a backend provider configuration, so the tfstate file will be created at a shared location and not locally.
When I apply plan terraform plan, I get the following warning.
Warning: "use_microsoft_graph": [DEPRECATED] This field now defaults to true and will be removed in v1.3 of Terraform Core due to the deprecation of ADAL by Microsoft.
The config files are as follows.
# Terraform Block
terraform {
required_version = ">= 1.0.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.0"
}
}
# Terraform State Storage to Azure Storage Container
backend "azurerm" {
resource_group_name = "storage-rg"
storage_account_name = "tfstatetrial"
container_name = "tfstatefiles"
key = "terraform.tfstate"
}
}
# Provider Block
provider "azurerm" {
features {}
}
# Resource-1: Azure Resource Group
resource "azurerm_resource_group" "myrg" {
name = "simple-rg" # local.rg_name
location = "centralindia" #var.resoure_group_location
}
I looked into this github issue, but could not find an answer.
The warning is because of the backend azurerm block. If I remove that(no remote state), then no warning comes up.
Any ideas what to be done?
This is a known "issue" and has been discussed at hashicorp/terraform#31118. tl;dr (as far as I understood):
The reasoning for this warning is [...] a temporary addition in 1.1, which has been flipped on in 1.2, and will be removed in 1.3
See also here:
use_microsoft_graph - (Optional) Should MSAL be used for authentication instead of ADAL, and should Microsoft Graph be used instead of Azure Active Directory Graph? Defaults to true.
Note: In Terraform 1.2 the Azure Backend uses MSAL (and Microsoft Graph) rather than ADAL (and Azure Active Directory Graph) for authentication by default - you can disable this by setting use_microsoft_graph to false. This setting will be removed in Terraform 1.3, due to Microsoft's deprecation of ADAL.
I know this is not technically a solution to your question or issue, but I think you'll be better off when subscribing and contributing to the GitHub issue instead of waiting for an answer here :)

Grails Database Migration plugin fails silently

I'm using Grails 3.3.6 (via sdkman) and when I try to use the dbmigration plugin to generate chagelog files it just doesn't do anything and can't figure out how to get more informative output out of the plugin. This is what's on my build.gradle:
buildscript {
...
dependencies {
...
classpath 'org.grails.plugins:database-migration:3.0.0'
...
runtime "mysql:mysql-connector-java:5.1.46"
}
}
This isn't a new project, I cloned it from a git repo and it is successfully running locally on my machine and several db migrations have been performed before (not on my machine, but the migrations folder has dozens of previous migrations, some generated with the plugin it seems). For some reason though, using the db migration plugin from the CLI isn't really working for me even though the project is successfully running locally. This is the output I get after modifying a model class:
[user#machine project-root]$ grails dbm-gorm-diff add-field-to-model.groovy --add
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/home/user/.sdkman/candidates/grails/3.3.6/lib/org.codehaus.groovy/groovy/jars/groovy-2.4.15.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Usage:
create-app [NAME] --profile=web
create-plugin [NAME] --profile=web-plugin
| Available Profiles
--------------------
* angular - A profile for creating Grails applications with Angular 5+
* rest-api - Profile for REST API applications
* base - The base profile extended by other profiles
* angularjs - A profile for creating applications using AngularJS
* plugin - Profile for plugins designed to work across all profiles
* profile - A profile for creating new Grails profiles
* react - A profile for creating Grails applications with a React frontend
* react-webpack - A profile for creating Grails applications with a React frontend using Webpack
* webpack - A profile for creating applications with node-based frontends using webpack 2
* web - Profile for Web applications
* rest-api-plugin - Profile for REST API plugins
* vue - A profile for creating Grails applications with a Vue.js frontend
* web-jboss7 - A Profile for Creating a JBoss 7.1 EAP Project
* web-plugin - Profile for Plugins designed for Web applications
Type 'grails help' or 'grails -h' for more information.
From what I've read online that warning is normal for certain versions of grails and/or groovy depending on your jdk version. The point is that the migration groovy script isn't generated as expected. I used variations grails envname dbm-gorm-diff --add add-field-to-model.groovy

How to select correct docker provider in terraform 0.14

To integrate with Docker, I've setup my terraform as follows:
The required provider:
docker = {
source = "kreuzwerker/docker"
version = "2.11.0"
}
the instantiation of that provider:
provider "docker" {
}
And finally I use it as follows in a resource:
data "docker_registry_image" "myapp" {
name = some_image_url
}
When I run terraform init, it seems it is still referring to the "old" terraform provider by HashiCorp:
Initializing modules...
Initializing the backend...
Initializing provider plugins...
- Finding hashicorp/random versions matching "3.0.1"...
- Finding hashicorp/null versions matching "~> 3.0.0"...
- Finding hashicorp/external versions matching "~> 2.0.0"...
- Finding kreuzwerker/docker versions matching "2.11.0"...
- Finding latest version of hashicorp/docker...
- Finding hashicorp/google versions matching "~> 3.56.0"...
- Finding hashicorp/azurerm versions matching "~> 2.46.1"...
- Installing hashicorp/null v3.0.0...
- Installed hashicorp/null v3.0.0 (signed by HashiCorp)
- Installing hashicorp/external v2.0.0...
- Installed hashicorp/external v2.0.0 (signed by HashiCorp)
- Installing kreuzwerker/docker v2.11.0...
- Installed kreuzwerker/docker v2.11.0 (self-signed, key ID 24E54F214569A8A5)
- Installing hashicorp/google v3.56.0...
- Installed hashicorp/google v3.56.0 (signed by HashiCorp)
- Installing hashicorp/azurerm v2.46.1...
- Installed hashicorp/azurerm v2.46.1 (signed by HashiCorp)
- Installing hashicorp/random v3.0.1...
- Installed hashicorp/random v3.0.1 (signed by HashiCorp)
Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/cli/plugins/signing.html
Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider
hashicorp/docker: provider registry registry.terraform.io does not have a
provider named registry.terraform.io/hashicorp/docker
If you have just upgraded directly from Terraform v0.12 to Terraform v0.14
then please upgrade to Terraform v0.13 first and follow the upgrade guide for
that release, which might help you address this problem.
Did you intend to use kreuzwerker/docker? If so, you must specify that source
address in each module which requires that provider. To see which modules are
currently depending on hashicorp/docker, run the following command:
terraform providers
When I run terraform providers I indeed see the reference, caused by docker_registry_image:
...
├── provider[registry.terraform.io/hashicorp/docker]
...
Notes:
All other providers are on their latest version.
I'm using terraform 0.14.6.
The resource given above is the only docker resource I'm using.
I've already tried using an alias on the provider and the resource, but it does not work.
How can I solve this? Thanks!
It seems like we didn't migrate correctly.
I've solved it by setting my terrorm version back to 0.13 and running terraform 0.13upgrade. After the command executed I upgraded to 0.14.6 again and all worked.
source: https://www.terraform.io/docs/cli/commands/0.13upgrade.html
What did the command do?
This created a file in my module folder (where I use a docker resource) called versions.tf with the following contents:
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
}
google = {
source = "hashicorp/google"
}
random = {
source = "hashicorp/random"
}
}
required_version = ">= 0.13"
}
Note that what is created here will depend on your specific situation.
It also created a file in my working directory that contained:
terraform {
required_version = ">= 0.13"
}
(The providers were in a different file and already had the correct docker source, hence only the required version addition was added to the new file.)

configure FreeRADIUS rlm_rest module in CentOS

I want to construct a 2 factor authentication system using freeRADIUS for proxy and privacyIDEA for authentication in server. I read some documents about freeRADIUS and privacyIDEA, and find that rlm_rest module could be helpful for this. I find this document in privacyIDEA webside:
http://privacyidea.readthedocs.io/en/master/application_plugins/rlm_rest.html#rlm-rest
and it just show how to install rlm_rest module in Ubuntu using apt-get, but my server is CentOS 7. So my first question is:
How to install the required packages of rlm_rest module in CentOS?
After that ,the document shows the configuration steps:
The authentication type needs to be configured in the /etc/freeradius/users file:
DEFAULT Auth-Type := rest
and the site configuration should invoke the module as follows:
authenticate {
Auth-Type rest {
rest
}
digest
unix
}
And I don`t know where I should invoke the “authenticate {…}”module? Does it should be write in /etc/freeradius/users ? This is my second question.
Could you please give me some advice or some references? Any help will be appreciate.
The authenticate section goes to your site configuration.
Also on CentOS this would be located in /etc/raddb/sites-enabled, which is linked to sites-available.
You should consider using the rlm_perl module, since this is more flexible.
http://privacyidea.readthedocs.io/en/master/application_plugins/rlm_perl.html#rlm-perl

Resources