Let's imagine we want to import an SNS Topic into our template.
We should have something like this, change region, to and id of the import.
terraform {
required_version = ">= 1.13.5"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.16.1"
}
}
}
# Configure the AWS provider
provider "aws" {
region = "us-east-1" # Replace with your desired region
}
import {
to = aws_sns_topic.AleTopic
id = "arn:aws:sns:us-east-1:XXXX:AleTopic"
}
Run to generate the config file for that resource
terraform plan -generate-config-out=generated.tf
A new file will be generated.
# __generated__ by Terraform
# Please review these resources and move them into your main configuration files.
# __generated__ by Terraform
resource "aws_sns_topic" "AleTopic" {
application_failure_feedback_role_arn = null
application_success_feedback_role_arn = null
application_success_feedback_sample_rate = 0
archive_policy = null
content_based_deduplication = false
delivery_policy = null
display_name = "My topic"
fifo_throughput_scope = null
Run terraform plan
Then run terraform apply to bring the changes to the state file.
No hay comentarios:
Publicar un comentario