Terraform:验证错误...成员必须满足正则表达式模式:arn:aws:iam::
Terraform: Validation error ... Member must satisfy regular expression pattern: arn:aws:iam::
我正在尝试通过 kinesis 数据流传输 rds,但它给我这个错误:
botocore.exceptions.ClientError: An error occurred
(ValidationException) when calling the PutRecord operation: 1
validation error detected: Value
'arn:aws:kinesis:us-west-2:xxxxxxxxxx:stream/rds-temp-leads-stream' at
'streamName' failed to satisfy constraint: Member must satisfy regular
expression pattern: [a-zA-Z0-9_.-]+
我该怎么做才能解决这个问题?
import json
import boto3
from datetime import datetime
from pymysqlreplication import BinLogStreamReader
from pymysqlreplication.row_event import (
DeleteRowsEvent,
UpdateRowsEvent,
WriteRowsEvent,
)
class DateTimeEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, datetime):
return o.isoformat()
return json.JSONEncoder.default(self, o)
def main():
mysql = {
"host": "",
"port":,
"user": "",
"passwd": "",
"db": ""}
kinesis = boto3.client("kinesis", region_name = 'us-west-2')
stream = BinLogStreamReader(
connection_settings = mysql,
server_id=100,
blocking = True,
log_file='mysql-bin.000003',
resume_stream=True,
only_events=[DeleteRowsEvent, WriteRowsEvent, UpdateRowsEvent])
for binlogevent in stream:
for row in binlogevent.rows:
print row
event = {"schema": binlogevent.schema,
"table": binlogevent.table,
"type": type(binlogevent).__name__,
"row": row
}
kinesis.put_record(StreamName="jhgjh", Data=json.dumps(event, cls=DateTimeEncoder), PartitionKey="default")
#print json.dumps(event)
if __name__ == "__main__":
main()
从流名称中删除'arn:aws:kinesis:us-west-2:xxxxxxxxxx:stream/rds-temp-leads-stream'。只需将流的名称放在那里,例如 "rds-temp-leads-stream"
基于错误:
1 validation error detected: Value 'arn:aws:kinesis:us-west-2:xxxxxxxxxx:stream/rds-temp-leads-stream' at 'streamName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z0-9_.-]+
突出显示的值:arn:aws:kinesis:us-west-2:xxxxxxxxxx:stream/rds-temp-leads-stream 与正则表达式不匹配 [a-zA-Z0-9_.-]+ 导致验证错误。
这是因为您不需要添加完整的 ARN,只需添加流的名称即可。即 rds-temp-leads-stream
我没有在代码中看到它,但很可能这一行出现了错误:
kinesis.put_record(StreamName="jhgjh", Data=json.dumps(event, cls=DateTimeEncoder), PartitionKey="default")
其中“StreamName”应遵循与上述相同的模式。参考资料如下:
https://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecord.html
对于我的情况,我还必须删除地址中的子文件夹,如下所示:
不正确
bucket='s3://image-video/image/'
photo='scene_academy.jpg'
client=boto3.client('rekognition')
response = client.detect_labels(Image={'S3Object':{'Bucket':bucket,'Name':photo}},
MaxLabels=10)
正确
bucket='image-video'
photo='image/scene_academy.jpg'
client=boto3.client('rekognition')
response = client.detect_labels(Image={'S3Object':{'Bucket':bucket,'Name':photo}},
MaxLabels=10)
运行时环境:AWS S3 存储桶
我正在尝试通过 kinesis 数据流传输 rds,但它给我这个错误:
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the PutRecord operation: 1 validation error detected: Value 'arn:aws:kinesis:us-west-2:xxxxxxxxxx:stream/rds-temp-leads-stream' at 'streamName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z0-9_.-]+
我该怎么做才能解决这个问题?
import json
import boto3
from datetime import datetime
from pymysqlreplication import BinLogStreamReader
from pymysqlreplication.row_event import (
DeleteRowsEvent,
UpdateRowsEvent,
WriteRowsEvent,
)
class DateTimeEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, datetime):
return o.isoformat()
return json.JSONEncoder.default(self, o)
def main():
mysql = {
"host": "",
"port":,
"user": "",
"passwd": "",
"db": ""}
kinesis = boto3.client("kinesis", region_name = 'us-west-2')
stream = BinLogStreamReader(
connection_settings = mysql,
server_id=100,
blocking = True,
log_file='mysql-bin.000003',
resume_stream=True,
only_events=[DeleteRowsEvent, WriteRowsEvent, UpdateRowsEvent])
for binlogevent in stream:
for row in binlogevent.rows:
print row
event = {"schema": binlogevent.schema,
"table": binlogevent.table,
"type": type(binlogevent).__name__,
"row": row
}
kinesis.put_record(StreamName="jhgjh", Data=json.dumps(event, cls=DateTimeEncoder), PartitionKey="default")
#print json.dumps(event)
if __name__ == "__main__":
main()
从流名称中删除'arn:aws:kinesis:us-west-2:xxxxxxxxxx:stream/rds-temp-leads-stream'。只需将流的名称放在那里,例如 "rds-temp-leads-stream"
基于错误:
1 validation error detected: Value 'arn:aws:kinesis:us-west-2:xxxxxxxxxx:stream/rds-temp-leads-stream' at 'streamName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z0-9_.-]+
突出显示的值:arn:aws:kinesis:us-west-2:xxxxxxxxxx:stream/rds-temp-leads-stream 与正则表达式不匹配 [a-zA-Z0-9_.-]+ 导致验证错误。
这是因为您不需要添加完整的 ARN,只需添加流的名称即可。即 rds-temp-leads-stream
我没有在代码中看到它,但很可能这一行出现了错误:
kinesis.put_record(StreamName="jhgjh", Data=json.dumps(event, cls=DateTimeEncoder), PartitionKey="default")
其中“StreamName”应遵循与上述相同的模式。参考资料如下: https://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecord.html
对于我的情况,我还必须删除地址中的子文件夹,如下所示:
不正确
bucket='s3://image-video/image/'
photo='scene_academy.jpg'
client=boto3.client('rekognition')
response = client.detect_labels(Image={'S3Object':{'Bucket':bucket,'Name':photo}},
MaxLabels=10)
正确
bucket='image-video'
photo='image/scene_academy.jpg'
client=boto3.client('rekognition')
response = client.detect_labels(Image={'S3Object':{'Bucket':bucket,'Name':photo}},
MaxLabels=10)
运行时环境:AWS S3 存储桶