I have CI CD pipeline where I was trying to import 2 versions into aws_secretsmanager_secret_version.example resource as shown below,
import {
to = aws_secretsmanager_secret_version.example
id = "arn:aws:secretsmanager:us-east-1:123456789012:secret:example-123456|xxxxx-xxxxxxx-xxxxxxx-xxxxx"
}
import {
to = aws_secretsmanager_secret_version.example
id = "arn:aws:secretsmanager:us-east-1:123456789012:secret:example-123456|yyyyy-yyyyyyy-yyyyyyy-yyyyy"
}
Error:
│ Error: Duplicate import configuration for "aws_secretsmanager_secret_version.example" │ │ on main.tf line 6: │ 6: import { │ │ An import block for the resource │ "aws_secretsmanager_secret_version.example" │ was already declared at main.tf:1,1-7. A resource can have only one import │ block.
Two versions can be imported into two different resource. For example, the first one can be called
version_xand the second oneversion_y:Import block also allows using
for_each, so you could try with that as well instead of having two resource blocks. An example:It should work with terraform versions >=1.7.x.