标签: aws-cloudformation

如何在Windows的aws云编队命令行工具中指定区域

我在命令行提交这个(我省略了我知道工作的所有其他参数)

aws cloudformation create-stack ... --parameters ParameterKey=Region,ParameterValue=us-east-1

它产生:

Unable to construct an endpoint for cloudformation in regionNone

如果我使用https://console.aws.amazon.com/cloudformation web ui 提交相同的参数,则可以使用.

如何使用aws.exe for windows指定区域?我用作模板的.json文件甚至将它作为默认值,但如果我从命令行中省略了区域,它仍然不会使用它

"Region":{"Type":"String","Description":"要启动的区域","默认":"us-east-1","AllowedValues":["us-east-1", "us-west-1","us-west-2","eu-west-1","ap-northeast-1"]}

在调试模式下我得到......

File "awscli\clidriver.pyc", line 206, in main
File "awscli\clidriver.pyc", line 354, in __call__
File "awscli\clidriver.pyc", line 461, in __call__
File "awscli\clidriver.pyc", line 555, in invoke
File "botocore\service.pyc", line 161, in get_endpoint
File "botocore\endpoint.pyc", line 265, in create_endpoint
File "botocore\regions.pyc", line 67, in construct_endpoint
UnknownEndpointError: Unable to construct an endpoint for cloudformation in …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-cloudformation

13
推荐指数
1
解决办法
1万
查看次数

如何将cloudwatch警报连接到lambda函数

如何将aws云监视警报连接到lambda函数调用?

我通过AWS CloudFormation模板以编程方式向我们创建的作为云形成堆栈一部分的ELB添加云监视警报.我希望将警报发送到lambda函数,该函数将消息发布到Slack.虽然警报有效,并且SNS配置对我来说似乎是正确的,但从不调用lambda函数.

lambda函数遵循以下示例:

https://medium.com/cohealo-engineering/how-set-up-a-slack-channel-to-be-an-aws-sns-subscriber-63b4d57ad3ea#.x2j9apedu

http://inopinatus.org/2015/07/13/hook-aws-notifications-into-slack-with-a-lambda-function/

lambda函数工作,我可以通过aws控制台发送测试数据,从而发送一条消息发送给Slack.

使用看起来正确的云监控警报创建负载均衡器:

在此输入图像描述

警报似乎配置为将警报发送到正确的SNS主题:

在此输入图像描述 在此输入图像描述

有一个SNS订阅该主题,lambda函数作为它的端点:

在此输入图像描述

警报触发时会触发警报并将消息发送到正确的主题:

在此输入图像描述

但是从不调用lambda函数:

在此输入图像描述

但是,如果我在lambda函数上手动添加SNS主题作为"事件源",则会在警报触发和发布Slack消息时调用它.

在此输入图像描述

我是否误解了如何将云监视报警连接到lambda函数?或者我缺少一个小细节?

如果这种方法不起作用,并且将lambda函数连接到云监视警报的唯一方法是将SNS主题添加为"事件源",通过AWS CloudFormation模板执行此操作的适当方法是什么?我没有看到修改现有资源的明显方法,例如固定的lambda函数.

这是我的CloudFormation模板:

"GenericSlackAlertSNSTopic" : {
    "Type" : "AWS::SNS::Topic",
    "Properties" : {
        "Subscription" : [ {
            "Endpoint" : "arn:aws:lambda:us-east-1:[...]:function:snsToSlack",
            "Protocol" : "lambda"
        } ]
    }
},
"ELBNoTrafficAlarm": {
    "Type": "AWS::CloudWatch::Alarm",
    "Properties": {
        "Namespace" : "AWS/ELB",
        "AlarmDescription": "Alarm for no apparent traffic on an ELB.",
        "AlarmActions": [{
            "Ref": "GenericSlackAlertSNSTopic"
        }],
        "InsufficientDataActions": [{
            "Ref": "GenericSlackAlertSNSTopic"
        }],
        "MetricName": "RequestCount",
        "Statistic": "Sum",
        "Dimensions" : [ {
            "Name" : "LoadBalancerName",
            "Value" …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services amazon-sns aws-cloudformation amazon-cloudwatch aws-lambda

13
推荐指数
1
解决办法
1万
查看次数

AWS SAM API与Cognito用户池授权程序

如何使用AWS SAM创建API,使用Cognito User Pools授权程序进行授权?

Theres AWS :: ApiGateway :: Authorizer.但......

{
  "Type" : "AWS::ApiGateway::Authorizer",
  "Properties" : {
    "AuthorizerCredentials" : String,
    "AuthorizerResultTtlInSeconds" : Integer,
    "AuthorizerUri" : String,
    "IdentitySource" : String,
    "IdentityValidationExpression" : String,
    "Name" : String,
    "ProviderARNs" : [ String, ... ],
    "RestApiId" : String,
    "Type" : String
  }
}
Run Code Online (Sandbox Code Playgroud)

它看起来像RestApiId是指使用此授权程序的API?但是使用AWS SAM,我的API被定义为

Resources:
  Ec2Index:
    Type: AWS::Serverless::Function
    Properties:
      Handler: ec2/index.handler
      Runtime: nodejs6.10
      CodeUri: ./src
      FunctionName: 'ApiEc2IndexHandler'
      Description: 'List EC2 resources'
      Timeout: 30
      Role: 'arn:aws:iam::598545985414:role/awsmanagement-lambda-management'
      Events:
        Ec2Index:
          Type: …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-cloudformation amazon-cognito

13
推荐指数
2
解决办法
4170
查看次数

AWS Lambda的动态环境变量,使用cloudformation模板

我必须在我的应用程序的各种堆栈中使用AWS lambda,因此我创建了一个通用的云形成模板来创建lambda函数.此模板可以包含在另一个云形成模板中,以进一步用作嵌套堆栈.

    # Basics
AWSTemplateFormatVersion: '2010-09-09'
Description: AWS CloudFormation Template to create a lambda function for java 8 or nodejs

# Parameters
Parameters:
  FunctionName:
    Type: String
    Description: Funciton Name
  HandlerName:
    Type: String
    Description: Handler Name
  FunctionCodeS3Bucket:
    Type: String
    Description: Name of s3 bucket where the function code is present
    Default: my-deployment-bucket
  FunctionCodeS3Key:
    Type: String
    Description: Function code present in s3 bucket
  MemorySize:
    Type: Number
    Description: Memory size between 128 MB - 1536 MB and multiple of 64
    MinValue: …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-cloudformation aws-lambda

13
推荐指数
1
解决办法
8042
查看次数

S3 存储桶中的 AWS Lambda 代码未更新

我正在使用 cloudformation 在启用版本控制的 S3Bucket 中使用代码创建我的 lambda 函数。

"MYLAMBDA": {
      "Type": "AWS::Lambda::Function",
      "Properties": {
        "FunctionName": {
          "Fn::Sub": "My-Lambda-${StageName}"
        },
        "Code": {
          "S3Bucket": {
            "Fn::Sub": "${S3BucketName}"
          },
          "S3Key": {
            "Fn::Sub": "${artifact}.zip"
          },
          "S3ObjectVersion": "1e8Oasedk6sDZu6y01tioj8X._tAl3N"
        },
        "Handler": "streams.lambda_handler",
        "Runtime": "python3.6",
        "Timeout": "300",
        "MemorySize": "512",
        "Role": {
          "Fn::GetAtt": [
            "LambdaExecutionRole",
            "Arn"
          ]
        }
      }
    }
Run Code Online (Sandbox Code Playgroud)

lambda 函数创建成功。当我将新的工件 zip 文件复制到 s3bucket 时,会使用新版本的“S3ObjectVersion”字符串创建该文件的新版本。但是 lambda 函数代码仍然使用旧版本。

aws cloudformation 的文档清楚地说明了以下内容

要更新源代码位于 Amazon S3 存储桶中的 Lambda 函数,您必须通过更新 S3Bucket、S3Key 或 S3ObjectVersion 属性来触发更新。单独更新源代码不会更新函数。

是否有额外的触发事件,我需要创建以更新代码?

aws-cloudformation aws-lambda

13
推荐指数
2
解决办法
1万
查看次数

CloudFormation 参数模板错误:参数不是字母数字

我在用

aws cloudformation validate-template --template-body file://template.json
Run Code Online (Sandbox Code Playgroud)

然后面对“CloudFormation Parameter Template Error : Parameter is non alphanumeric”错误,以下代码显示了我的params.jsontemplate.json文件。

参数文件

[
    {
        "ParameterKey": "name_for_abc",
        "ParameterValue": "abc"
    }
]
Run Code Online (Sandbox Code Playgroud)

模板文件

{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Transform": "AWS::Serverless-2016-10-31",
    "Description": "some text",
    "Parameters": {
        "name": {
            "Description": "name_of_abc",
            "Type": "String"
        }
    },
    "Resources": {
        "LambdaFunctionAuto": {
            "Type": "AWS::Serverless::Function",
            "Properties": {
                "Environment": {
                    "Variables": {
                        "name_of_abc": {
                            "Ref": "name_of_abc"
                        }
                    }
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

parameters amazon-web-services aws-cloudformation

13
推荐指数
1
解决办法
1万
查看次数

如何在 CloudWatch 中查看 AWS CloudFormation 日志?

我无法在 CloudFormation 控制台中查看 CloudFormation 堆栈集操作日志。尽管每个堆栈集操作都有一个“操作 ID”,但是否可以在 CloudWatch 中查看日志?或者某种方法来打开日志记录?

amazon-web-services aws-cloudformation

13
推荐指数
1
解决办法
5930
查看次数

CloudFormation 资源创建(如果不存在)

我想用 CloudFormation 创建 Route53 HostedZone,所以我想检查一下 Route53 中关于 HostedZone 的一些信息是否存在。

在我的情况下,我需要检查资源是否存在,忽略资源创建。我该如何处理这个问题。

我的 CloudFormation 模板如下所示。

"myDNSRecord" : {
  "Type" : "AWS::Route53::RecordSet",
  "Properties" : {
    "HostedZoneName" : { "Ref" : "HostedZoneResource" },
    "Comment" : "DNS name for my instance.",  
    "Name" : {
      "Fn::Join" : [ "", [
        {"Ref" : "Ec2Instance"}, ".",
        {"Ref" : "AWS::Region"}, ".",
        {"Ref" : "HostedZone"} ,"."
      ] ]
    },
    "Type" : "A",
    "TTL" : "900",
    "ResourceRecords" : [
      { "Fn::GetAtt" : [ "Ec2Instance", "PublicIp" ] }
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-cloudformation devops infrastructure-as-code

13
推荐指数
1
解决办法
1万
查看次数

在 CloudFormation 中更新用户数据时强制更换 EC2 实例

我正在使用模板中的UserData字段在CloudFormation实例上安装软件。当我更新时,UserData我想CloudFormation替换实例。但是,UserData不是替换字段,因此实例停止但未替换,新UserData脚本永远不会运行。

有没有一种方法,我可以更新UserDataCloudFormation

我指的是这个文档

templates amazon-ec2 amazon-web-services aws-cloudformation

13
推荐指数
1
解决办法
727
查看次数

AWS CDK 生成的资源标识符非常糟糕且不可读。有任何解决这个问题的方法吗?

任何使用 AWS CDK 的人都会遭受可怕的资源标识符。

堆栈/嵌套堆栈名称示例:

在此处输入图片说明

或资源名称示例:

在此处输入图片说明

这些标识符读起来很糟糕。是否有任何解决方法来覆盖这些标识符?

我试图设置资源的 ID/名称/标识符/别名。然而,似乎 cdk 或 cloudformation 本身正在生成这些字符串。

谢谢你的建议!

amazon-web-services aws-cloudformation aws-cdk

13
推荐指数
1
解决办法
2136
查看次数