我是Terraform的新手,在尝试使用.tf文件的环境变量时遇到了一些问题,我尝试使用terraform.tfvars/ variables.tf.
./terraform apply -var-file="terraform.tfvars"
Failed to load root config module: Error parsing variables.tf: At 54:17: illegal char
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?
Terraform版本: Terraform v0.9.2
main.tf:
provider "aws" {
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
region = "${var.aws_region}"
allowed_account_ids = ["${var.aws_account_id}"]
}
resource "aws_instance" "db" {
ami = "ami-49c9295"
instance_type = "t2.micro"
tags {
Name = "test"
}
connection {
user = "ubuntu"
}
security_groups = ["sg-ccc943b0"]
availability_zone = "${var.availability_zone}"
subnet_id = "${var.subnet_id}"
}
Run Code Online (Sandbox Code Playgroud)
terraform.tfvars:
aws_profile = "default"
aws_access_key = …Run Code Online (Sandbox Code Playgroud) 我尝试使用batchGetItem从表中返回多个项目的属性,但似乎它仅适用于分区键和范围键的组合,但是如果我只想通过主键识别请求的项目怎么办?唯一的方法是创建没有范围键的表吗?
// Adding items
$client->putItem(array(
'TableName' => $table,
'Item' => array(
'id' => array('S' => '2a49ab04b1534574e578a08b8f9d7441'),
'name' => array('S' => 'test1'),
'user_name' => array('S' => 'aaa.bbb')
)
));
// Adding items
$client->putItem(array(
'TableName' => $table,
'Item' => array(
'id' => array('S' => '4fd70b72cc21fab4f745a6073326234d'),
'name' => array('S' => 'test2'),
'user_name' => array('S' => 'aaaa.bbbb'),
'user_name1' => array('S' => 'aaaaa.bbbbb')
)
));
$client->batchGetItem(array(
"RequestItems" => array(
$table => array(
"Keys" => array(
// hash key
array(
"id" => array( 'S' …Run Code Online (Sandbox Code Playgroud) 我对AWS elasticsearch可用区域感知和副本有一些疑问:
根据我的理解,如果区域/节点发生故障,如果在节点之间复制了分片,则群集将能够完全恢复,并且我将在每个区域中拥有整个数据副本,这是正确的吗?
根据AWS elasticsearch文档,我必须使用Amazon elasticsearch API跨可用区中的节点复制Amazon elasticsearch集群的数据.但我找不到通过Amazon elasticsearch API配置副本的方法,所以我想通过Elastic API,对吧?
在同一区域sa-east1中的两个可用区域之间进行集群节点分配的最佳做法是什么,至少在新环境的开始时,有多少专用主实例和数据节点应足以进行故障转移?2个专用主站和2个数据节点应该足以防止数据丢失和发生故障时的停机时间?我想应该为索引配置1个副本.我还想到每个索引有2-3个专用主节点和3个数据节点以及2个副本.
AWS elasticsearch中没有设置文件,更改副本数量的唯一方法是通过弹性API,但我无法找到更改默认设置的方法,当新索引创建副本分片数为1时,它是默认值,有没有办法更改每个新索引的默认设置?
像这样的东西只会改变当前的索引.
curl -XPUT 'https://search-aa1-a3qlyghdz2i6wszffnv4iz5cyi.sa-east-1.es.amazonaws.com/_all/_settings' -d '
{
"index" : {
"number_of_replicas" : 2
}
}'Run Code Online (Sandbox Code Playgroud)
http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-managedomains.html
感谢您提供任何帮助 !
我是 python pymysql 的新手(我在 Ruby 之前使用过 Mysql2 gem),我想从 mysql 表中获取键和值并执行一些操作:
例如:
dbconnection = pymysql.connect(host=mysql_hostname, user=mysql_username, password=mysql_pass, db=mysql_schema, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor)
cursor = dbconnection.cursor()
_SQL = ("""
select * ...
""")
cursor.execute(_SQL)
result = cursor.fetchall()
for row in result:
print(row)
print("\n")
# How can I access each key and each value for example: STATUS is the value and 3 is the key
# I want to do something like this:
#'if the value of 'CAP' > 1: change the value of status …Run Code Online (Sandbox Code Playgroud) 我在 Lambda 中有一个函数,仅当对象发生更改时,该函数才应将元数据标头添加到 s3 上的对象。
ContentType: 'application/javascript'
CacheControl: 'max-age=600'Run Code Online (Sandbox Code Playgroud)
但事实证明,Lambda 每秒检查存储桶大约 100 次,不仅是对象是否发生变化,而且成本很高。
S3访问日志:
b6234e2652b93344f7 aa [02/Mar/2016:11:00:55 +0000] 54.0.0.209 arn:aws:sts::718436:assumed-role/lambda_s3_exec_role/awslambda_642_201609 805 REST.COPY.OBJECT /local.js "PUT /local.js HTTP/1.1" 200 - 234 4404 50 24 "-" "aws-sdk-nodejs/2.2.32 linux/v0.10.36" -
b6234ee5f9cf0344f7 aa [02/Mar/2016:11:00:55 +0000] 54.0.0.209 arn:aws:sts::71836:assumed-role/lambda_s3_exec_role/awslambda_642_209 890005 REST.COPY.OBJECT_GET local.js - 200 - - 4404 - - - - -Run Code Online (Sandbox Code Playgroud)
功能:
console.log('Loading function');
var aws = require('aws-sdk');
var s3 = new aws.S3({ apiVersion: '2006-03-01' });
exports.handler = function(event, context) {
//console.log('Received event:', JSON.stringify(event, null, 2)); …Run Code Online (Sandbox Code Playgroud)我正在使用batchGetItem方法来检索 x 个项目,并使用它ProjectionExpression来检索每个项目的 x 个属性。
$result = $client->batchGetItem(array(
'RequestItems' => array(
$table => array(
'Keys' => $keys,
'ConsistentRead' => true,
'ProjectionExpression' => "id, name"
),
),
));
$read_items = $result->getPath("Responses/{$table}");
Run Code Online (Sandbox Code Playgroud)
然而,我的一些项目具有诸如name和 之类的属性token,这些属性是 DynamoDB 中的保留字。
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html
{"__type":"com.amazon.coral.validate#ValidationException","message":"Invalid ProjectionExpression: Attribute name is a r (truncated...)
ValidationException (client): Invalid ProjectionExpression: Attribute name is a reserved keyword; reserved keyword: name - {"__type":"com.amazon.coral.validate#ValidationException","message":"Invalid ProjectionExpression: Attribute name is a reserved keyword; reserved keyword: name"}
Filename: /var/app/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php
Run Code Online (Sandbox Code Playgroud)
据我所知,expression …
这是我的代码:
region = ARGV[0]
instance_name = ARGV[1]
Run Code Online (Sandbox Code Playgroud)
这样它的作用:
raise RuntimeError, 'empty argument' if ARGV[0].nil?
raise RuntimeError, 'empty argument' if ARGV[1].nil?
Run Code Online (Sandbox Code Playgroud)
这样它不起作用:
我尝试了所有这些
ARGV.each do |a|
raise RuntimeError, 'empty argument' if "#{a}".nil?
raise RuntimeError, 'empty argument' if a.nil?
raise RuntimeError, 'empty argument' if "#{a}".empty?
raise RuntimeError, 'empty argument' if a.empty?
end
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
谢谢.