小编Ara*_*nde的帖子

有没有办法使用cloudformation或AWS CLI创建AWS Dashboard

我想使用cloudformation创建一个AWS Dashboard,但确实找到了方法.猜猜AWS尚未增加对此的支持.

作为替代方案,可以使用AWS CLI创建它

amazon-web-services aws-cloudformation

5
推荐指数
1
解决办法
1741
查看次数

使用带有 Node.js 的 AWS Lambda 函数从 S3 存储桶中提取 zip 文件并上传到另一个存储桶

荫玩弄着AWS LambdaNode.js。我创建了一个 lambda 函数并使用S3 event. 我想提取上传到 S3 的 zip 文件并将提取的文件上传到同一个存储桶上的另一个文件夹。

我从以下代码中获取存储桶和文件信息,但之后我不知道如何提取并上传到 s3。

任何建议或代码块都会对我有所帮助。

'use strict';

console.log('Loading function to get all latest object from S3 service');

const aws = require('aws-sdk');

const s3 = new aws.S3({ apiVersion: '2006-03-01' });


exports.handler = (event, context, callback) => {
    console.log('Received event:', JSON.stringify(event, null, 2));

    // Get the object from the event and show its content type
    const bucket = event.Records[0].s3.bucket.name;
    const key = decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, ' '));
    const params = …
Run Code Online (Sandbox Code Playgroud)

lambda amazon-s3 amazon-web-services node.js aws-lambda

5
推荐指数
1
解决办法
9250
查看次数

使用 boto3 在 SQS 中创建一个 fifo 队列

任何人都可以帮助我使用 boto3 在 sqs 中创建一个 fifo 队列。试过了,但这不起作用

sqs.create_queue(QueueName='test', Attributes={'FifoQueue':'true’})
Run Code Online (Sandbox Code Playgroud)

amazon-sqs amazon-web-services boto3

5
推荐指数
2
解决办法
1994
查看次数

天真的安装PySpark还支持S3访问

我想从PySpark读取存储在S3上的Parquet数据。

我从这里下载了spark:

http://www.apache.org/dist/spark/spark-2.1.0/spark-2.1.0-bin-hadoop2.7.tgz
Run Code Online (Sandbox Code Playgroud)

并天真地将其安装到Python

cd python
python setup.py install
Run Code Online (Sandbox Code Playgroud)

这似乎工作正常,我可以导入pyspark,创建SparkContext等。但是,当我阅读一些可公开访问的镶木地板数据时,会得到以下信息:

import pyspark
sc = pyspark.SparkContext('local[4]')
sql = pyspark.SQLContext(sc)
df = sql.read.parquet('s3://bucket-name/mydata.parquet')
Run Code Online (Sandbox Code Playgroud)

我收到以下异常

Py4JJavaError: An error occurred while calling o55.parquet.
: java.io.IOException: No FileSystem for scheme: s3
    at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2660)
    at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2667)
    at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:94)
    at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2703)
    at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2685)
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:373)
    at org.apache.hadoop.fs.Path.getFileSystem(Path.java:295)
    at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$14.apply(DataSource.scala:372)
    at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$14.apply(DataSource.scala:370)
    at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241)
    at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:241)
    at scala.collection.immutable.List.flatMap(List.scala:344)
    at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:370)
    at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:152)
    at org.apache.spark.sql.DataFrameReader.parquet(DataFrameReader.scala:441)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at …
Run Code Online (Sandbox Code Playgroud)

python amazon-s3 amazon-web-services apache-spark pyspark

5
推荐指数
1
解决办法
4841
查看次数

aws apigateway lambda 总是返回 502

我已经为我的代理服务器创建了 aws apigateway lambda 集成。当我向网关发出 get 请求时,请求成功通过。lambda 函数也成功执行并在输出流中写入响应,statusCode 为 200。但 apigateway 始终返回 502。

handleRequest() 的片段:

 BufferedReader reader = new BufferedReader(new 
        InputStreamReader(inputStream));
        JSONObject event = (JSONObject) parser.parse(reader);
        request = Input.builder().setEvent(event).build();

    Response response = requestManager.handleRequest(request);
    logger.log(String.format("Response [%s]", response.toString()));

    JSONObject responseJson = new JSONObject();
    responseJson.put("statusCode", response.getStatusCode());
    responseJson.put("headers", response.getHeaders());
    JSONObject jsonBody = (JSONObject) parser.parse(response.getBody());
    responseJson.put("body", jsonBody);
    OutputStreamWriter writer = new OutputStreamWriter(outputStream, "UTF-8");
    logger.log("response recieved");
    logger.log(String.format("responseJson [%s]", responseJson));
    writer.write(responseJson.toJSONString());
    writer.close();
    logger.log(String.format("output stream [%s]", outputStream));
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?

amazon-web-services aws-lambda aws-api-gateway

5
推荐指数
1
解决办法
3067
查看次数

AWS SNS创建超时

调用Lambda函数时,它会创建SNS主题,向其添加订阅者,然后向其发布消息。发布消息后,它将删除主题。要创建的主题名称和订阅者将作为有效负载提供给lambda函数。

有时它会工作,有时会失败,Task timed out after x seconds因为我增加了Lambda超时时间,但仍然是同样的问题。

我挖了一点,发现

sns.createTopic(params, function(err, data) {
    if(err) {
        console.log('Error Creating SNS Topic:',err);
    } else {
        console.log('SNS Topic Created Successfully:',data);
    }
}
Run Code Online (Sandbox Code Playgroud)

永不返回,没有错误,没有数据,我看不到结果 console.log()

当它工作时,一切都很好,但是当它失败时,我看不到找到问题。

编辑:

因此,我做了更多的挖掘工作,我将SNS主题创建的超时时间默认为5分钟,现在为5秒。当失败发生时,我得到这个“

{ [TimeoutError: Connection timed out after 5000ms]
message: 'Connection timed out after 5000ms',
code: 'NetworkingError',
time: Thu Mar 30 2017 15:35:20 GMT+0000 (UTC),
region: 'us-east-1',
hostname: 'sns.us-east-1.amazonaws.com',
retryable: true }
Run Code Online (Sandbox Code Playgroud)

amazon-web-services amazon-sns aws-lambda

5
推荐指数
2
解决办法
718
查看次数

AWSS3GetObjectRequest.ifModifiedSince似乎不起作用

我无法让ifModifiedSince工作.这是我的代码:

func updateDatabase()
{
    let objectRequest = AWSS3GetObjectRequest()
    objectRequest?.key = "wa/wa2016/idahoGmu.tiff"
    objectRequest?.bucket = bucketName

    let dateComponents = NSDateComponents()
    dateComponents.day = 10
    dateComponents.month = 4
    dateComponents.year = 2018
    let date = NSCalendar.current.date(from: dateComponents as DateComponents)

    // TODO This isn't working.  It grabs the file regardless of date.
    objectRequest?.ifModifiedSince = date

    let s3 = AWSS3.default()

    s3.getObject(objectRequest!).continueWith
    {
        (task) -> AnyObject! in if let error = task.error
        {
            print("Error: \(error.localizedDescription)")
        }

        if let result = task.result
        {
            let fileManager = FileManager.default
            let documents …
Run Code Online (Sandbox Code Playgroud)

amazon-s3 amazon-web-services ios swift aws-sdk

5
推荐指数
1
解决办法
195
查看次数

S3.getSignedUrl 接受多种内容类型

我正在使用react-s3-uploader节点包,它接受一个signingUrl用于获取用于将对象存储到S3中的signedUrl。

目前,我已经配置了一个 lambda 函数(带有 API 网关端点)来生成此signedUrl。经过一番修补后,我已经让它可以工作了,但注意到我必须在 lambda 函数中定义content-type,如下所示:

var AWS = require('aws-sdk');
const S3 = new AWS.S3()
AWS.config.update({
  region: 'us-west-2'
})

exports.handler = function(event, context) {
  console.log('context, ', context)
  console.log('event, ', event)
  var params = {
    Bucket: 'video-bucket',
    Key: 'videoname.mp4',
    Expires: 120,
    ACL: 'public-read',
    ContentType:'video/mp4'
  };
  S3.getSignedUrl('putObject', params, function (err, url) {
    console.log('The URL is', url);
    context.done(null, {signedUrl: url})
  });  
}
Run Code Online (Sandbox Code Playgroud)

问题是我希望这个签名的 url 能够接受多种类型的视频文件,并且我尝试设置ContentTypevideo/*,但这不起作用。另外,因为这个 lambda 端点并不是实际进行上传的端点,所以我无法事先将文件类型传递给该函数。

amazon-s3 amazon-web-services node.js aws-sdk aws-lambda

5
推荐指数
1
解决办法
7071
查看次数

AWS RDS Aurora Reader 复制到外部 MySql 实例

我想使用 AWS aurora 副本作为外部 MySQL 实例的主实例。

我创建了一个 Aurora 实例和一个只读副本,其中启用了 BinLog 的数据库集群参数。

从写入器复制工作正常,但我无法看到只读副本的 bin_log 参数 ON。

有什么方法可以实现这一目标吗?

mysql amazon-web-services amazon-aurora

5
推荐指数
1
解决办法
863
查看次数

编写用于AWS Lambda的异步代码的正确方法是什么?

我写了以下代码:


import asyncio

loop = asyncio.get_event_loop()

async def get_urls(event):

    return {'msg':'Hello World'}

def lambda_handler(event,context):

    return loop.run_until_complete(get_urls(event))
Run Code Online (Sandbox Code Playgroud)

我试图完成以下步骤,但速度更快。


def lambda_handler(event, context):
    # TODO implement
    return {'msg':'Hello World'}
Run Code Online (Sandbox Code Playgroud)

在AWS Lambda环境中编写此代码的正确方法是什么?

python amazon-web-services python-3.x python-asyncio aws-lambda

5
推荐指数
3
解决办法
2265
查看次数