在 terraform 中有一个在 aws 中创建 EC2 机器的示例。
# Create a new instance of the latest Ubuntu 20.04 on an
# t3.micro node with an AWS Tag naming it "HelloWorld"
provider "aws" {
region = "us-west-2"
}
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["099720109477"] # Canonical
}
resource "aws_instance" "web" {
ami = data.aws_ami.ubuntu.id
instance_type = "t3.micro"
tags = { …Run Code Online (Sandbox Code Playgroud) 通过以下内容,我可以循环遍历资源块,轻松地将路由表关联添加到“所有”子网。但是,我只需要为我的公共子网创建关联。
我怎样才能使这个“if”语句起作用?或者任何其他方式来过滤each.value.class == "pub"此事。
resource "aws_route_table_association" "rtb-pub" {
for_each = local.subnets_map
if each.value.class == "pub" ## <---- how?
route_table_id = aws_route_table.rtb-pub.id
subnet_id = aws_subnet.map["${each.value.subnet}"].id
}
Run Code Online (Sandbox Code Playgroud)
提前致谢!
我的想法是,我想使用 Terraform 资源aws_secretsmanager_secret仅创建三个秘密(不是工作区指定的秘密),一个用于开发环境,一个用于 preprod,第三个用于生产环境。
就像是:
resource "aws_secretsmanager_secret" "dev_secret" {
name = "example-secret-dev"
}
resource "aws_secretsmanager_secret" "preprod_secret" {
name = "example-secret-preprod"
}
resource "aws_secretsmanager_secret" "prod_secret" {
name = "example-secret-prod"
}
Run Code Online (Sandbox Code Playgroud)
但是创建它们之后,我不想每次运行“Terraform apply”时都覆盖它们,有没有办法告诉 Terraform 是否存在任何秘密,跳过秘密的创建并且不覆盖?
我查看了此页面,但仍然没有明确的解决方案,任何建议将不胜感激。
amazon-web-services terraform terraform-provider-aws aws-secrets-manager
我在 Github 的几个terraform代码中发现了一个模式。
resource "aws_vpc" "this"
Run Code Online (Sandbox Code Playgroud)
我想知道关键字如何this提供相对于命名资源的特殊优势。我找不到有关关键字的Hashicorp文档this。
https://github.com/cloudposse/terraform-aws-vpn-connection/blob/master/context.tf
我在Zend Framework中为Ubuntu 9.10上的"Apache friends - xampp"服务器1.7.1上的文件上传做了一些表格.
我的问题是我要为这个上传添加进度条,因为xampp服务器在我的localhost上,文件上传速度非常快.因此,我没有时间检查或观察进度条是否正常工作.
有一种简单的方法(PHP,Zend Framework或Apache中的一些选项)可以将文件上传速度降低到例如20kB/s.
我尝试将mod_bw用于Apache,但它似乎只限制从服务器下载,而不是上传到服务器.我也尝试上传大文件,比如400MB,但这并不好,因为我的网页浏览器几乎崩溃了.
我想从 terraform 中的字符串列表中排除给定的字符串
示例:我有以下数据源作为变量
region_list = data.oci_identity_region_subscriptions.region_subscriptions.region_subscriptions.*.region_name
Run Code Online (Sandbox Code Playgroud)
现在,我想从中排除一个区域。区域“us-ashburn-1”
从region_list中排除(“us-ashburn-1”)。关于如何做到这一点有什么想法吗?
我使用 HTML 和 Javascript 在 S3 上上传文件。我面临一个问题 --> 我为未经身份验证的实体创建了一个角色,并为其分配了以下策略。
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:putObject"
],
"Resource": [
"arn:aws:s3:::bucket-name/*"
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
我收到访问被拒绝错误。但是当我授予权限时
“s3:*”我能够上传文件。我可以授予什么最低权限才能完成这项工作
我正在使用以下定义创建一系列 s3 存储桶:
resource "aws_s3_bucket" "map" {
for_each = local.bucket_settings
bucket = each.key
...
}
Run Code Online (Sandbox Code Playgroud)
我想输出网站端点的列表:
output "website_endpoints" {
# value = aws_s3_bucket.map["example.com"].website_endpoint
value = ["${keys(aws_s3_bucket.map)}"]
}
Run Code Online (Sandbox Code Playgroud)
提取端点列表(而不是完整的对象属性)的语法是什么?
我有一个 cloudformation 堆栈(从 stack_master 生成),资源已经创建,但我想将其放入无服务器框架中。我已经添加了资源部分,但它创建了新的堆栈。我希望堆栈更新现有堆栈以及从那里进行的任何更新。谢谢
我希望能够在单个Zend Form元素上添加多个PregReplace过滤器.我可以使用以下代码添加一个PregReplace过滤器:
$word = new Zend_Form_Element_Text('word');
$word->addFilter('PregReplace', array(
'match' => '/bob/',
'replace' => 'john'
));
$this->addElement($word);
Run Code Online (Sandbox Code Playgroud)
我试过了
$word = new Zend_Form_Element_Text('word');
$word->addFilter('PregReplace', array(
'match' => '/bob/',
'replace' => 'john'
));
$word->addFilter('PregReplace', array(
'match' => '/sam/',
'replace' => 'dave'
));
$this->addElement($word);
Run Code Online (Sandbox Code Playgroud)
但这仅仅意味着第二个过滤器工作.
如何添加多个PregReplace过滤器?