Son*_*ati 5 amazon-s3 amazon-web-services terraform terraform-provider-aws
使用一个 .tf 文件,其中包括创建 s3 存储桶、ec2 和安全组,我担心的是,如果我运行 terraform apply 并且它在中间中止后成功创建了 s3 存储桶。在上面的情况下,我想回滚 terraform apply 运行后发生的所有更改。
一旦 .tf 文件开始运行,我就中止该进程,但更改不会回滚。
provider "aws" { }
resource "aws_instance" "example" {
ami = "ami-2757f631"
instance_type = "t2.micro"
}
resource "aws_s3_bucket" "b" {
bucket = "my-tf-test-bucket"
acl = "private"
tags = {
Name = "My bucket"
Environment = "Dev"
}
}
resource "aws_security_group" "allow_rdp" {
name = "allow_rdp"
description = "Allow rdp traffic"
ingress {
from_port = 3389 # By default, the windows server listens on TCP port 3389 for RDP
to_port = 3389
protocol = "tcp"
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7582 次 |
| 最近记录: |