-
Notifications
You must be signed in to change notification settings - Fork 133
fix(iam_ssh_key): do not read public key in resource #2695
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
fix(iam_ssh_key): do not read public key in resource #2695
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2695 +/- ##
==========================================
- Coverage 71.43% 67.69% -3.74%
==========================================
Files 277 339 +62
Lines 35875 40108 +4233
==========================================
+ Hits 25628 27153 +1525
- Misses 8028 10647 +2619
- Partials 2219 2308 +89 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Could you do additional testing to ensure that the formatting happening in the terraform state is consistant with the key stored on the IAM backend? |
This caused the value to differ from requested input and this can lead to issue in terraform if the value is used in other resources. Also as it cannot be updated, it seems right to assume the local key is the correct key
2816600 to
ad2803f
Compare
|
My test config to reproduce issue: provider "scaleway" {
alias = "project"
}
resource "scaleway_account_project" "project" {
provider = scaleway.project
}
provider "scaleway" {
project_id = scaleway_account_project.project.id
}
resource "scaleway_iam_ssh_key" "key1" {
public_key = "<key with comment>"
}
resource "scaleway_iam_ssh_key" "key2" {
public_key = "<key with comment>"
}
locals {
ssh_keys_hash = sha256(join(",", [
scaleway_iam_ssh_key.key1.public_key,
scaleway_iam_ssh_key.key2.public_key,
]))
}
resource "scaleway_vpc_public_gateway_ip" "ip" {}
resource "scaleway_vpc_public_gateway" "main" {
ip_id = scaleway_vpc_public_gateway_ip.ip.id
name = "public_gateway_demo"
type = "VPC-GW-S"
tags = ["demo", "terraform"]
bastion_enabled = true
bastion_port = 61000
refresh_ssh_keys = local.ssh_keys_hash
} |
|
Terraform does not allow required fields to be computed. This means that we cannot rely on API for its formatting of the key. In my given config, we can use a variable to store key and use this variable for key creation and hashing. |
This caused the value to differ from requested input and this can lead to issue in terraform if the value is used in other resources.
Also as it cannot be updated, it seems right to assume the local key is the correct key