标签: troposphere

尝试将参数从Master传递到子模板

我正在尝试将列表参数从主模板传递到子模板,但是我遇到了两个错误.这些是我在主模板上的当前参数.

"Parameters": {
    "ELBSubnets": {
        "Default": "subnet-5d8fea67,subnet-3e35cf15",
        "Type": "CommaDelimitedList"
    },
    "LCKeyPair": {
        "Default": "key-master",
        "Type": "String"
    },
    "LCSecurityGroups": {
        "Default": "sg-10a15c74,sg-880e5fec",
        "Type": "CommaDelimitedList"
    }
},
Run Code Online (Sandbox Code Playgroud)

传递给子模板时,它们在同一模板上的此方法中被引用.

    "ChildTempate1": {
        "Properties": {
            "Parameters": {
                "ELBSubnets": {
                    "Ref": "ELBSubnets"
                },
                "KeyPair": {
                    "Ref": "LCKeyPair"
                },
                "LCSecurityGroups": {
                    "Ref": "LCSecurityGroups"
                }
            },
Run Code Online (Sandbox Code Playgroud)

在子模板上,它们被声明完全相同.

"Parameters": {
    "ELBSubnets": {
        "Type": "CommaDelimitedList"
    },
    "LCKeyPair": {
        "Type": "String"
    },
    "LCSecurityGroups": {
        "Type": "CommaDelimitedList"
    }
},
Run Code Online (Sandbox Code Playgroud)

并且它们在子模板中的此方法中被引用.

            "KeyName": {
                "Ref": "LCKeyPair"
            },
            "SecurityGroups": {
                "Fn::Join": [
                    ",",
                    [
                        { …
Run Code Online (Sandbox Code Playgroud)

json amazon-web-services aws-cloudformation troposphere

10
推荐指数
2
解决办法
8688
查看次数

将 CloudFormation 模板 (YAML) 转换为对流层代码

我有一个用 Yaml 编写的大型 CloudFormation 模板,我想开始使用对流层。有没有什么简单的方法可以将 CF 模板转换为对流层代码?

我在这里注意到这个脚本https://github.com/cloudtools/troposphere/blob/master/troposphere/template_generator.py 这会创建一个对流层 python 对象,但我不确定是否可以输出它对流层代码。

aws-cloudformation troposphere aws-cdk

8
推荐指数
1
解决办法
1223
查看次数

使用对流层进行云形成,如何在标签上添加“启动时传播”

我正在使用python模块对流层在我的云形成模板中生成标签。当前脚本生成:

       "Tags": [{"Key":"Name", "Value":"MyTagName"}, 
                {"Key":"Version", "Value":"123456"}]
Run Code Online (Sandbox Code Playgroud)

但我需要产生

       "Tags":[{"Key":"Name", "Value":"MyTagName", "PropagateAtLaunch":"true"},
               {"Key":"Version", "Value":"123456", "PropagateAtLaunch":"true"}]
Run Code Online (Sandbox Code Playgroud)

适用的脚本部分为:

    asg = autoscaling.AutoScalingGroup("MyASG")
    asg.Tags = Tags(Name = "MyTagName", Version = "123456")
    t.add_resource(asg)
Run Code Online (Sandbox Code Playgroud)

python aws-cloudformation aws-cli troposphere

7
推荐指数
1
解决办法
4096
查看次数

存储桶日志记录表单 Applicationloadbalancer 的访问被拒绝:请检查 S3bucket 权限

Access Denied for bucket: appdeploy-logbucket-1cca50r865s65. 
Please check S3bucket permission (Service: AmazonElasticLoadBalancingV2; Status Code: 400; Error Code: 
InvalidConfigurationRequest; Request ID: e5e2245f-2f9b-11e9-a3e9-2dcad78a31ec)
Run Code Online (Sandbox Code Playgroud)

我想将我的 ALB 日志存储到 s3 存储桶,我已向 s3 存储桶添加了策略,但它说访问被拒绝,我已经尝试了很多,并使用了很多配置,但它一次又一次失败,并且我的堆栈回滚,我曾经用来Troposphere创建模板。

我已经尝试使用我的策略,但它不起作用。

BucketPolicy = t.add_resource(
    s3.BucketPolicy(
        "BucketPolicy",
        Bucket=Ref(LogBucket),
        PolicyDocument={
            "Id": "Policy1550067507528",
            "Version": "2012-10-17",
            "Statement": [
              {
                   "Sid": "Stmt1550067500750",
                   "Action": [
                    "s3:PutObject",
                    "s3:PutBucketAcl",
                    "s3:PutBucketLogging",
                    "s3:PutBucketPolicy"
                   ],
                   "Effect": "Allow",
                   "Resource": Join("", [
                     "arn:aws:s3:::",
                     Ref(LogBucket),
                     "/AWSLogs/",
                     Ref("AWS::AccountId"),
                     "/*"]),
                   "Principal": {"AWS": "027434742980"},
              }
            ],
            },
    ))
Run Code Online (Sandbox Code Playgroud)

有什么帮助吗?

load-balancing amazon-s3 amazon-web-services aws-cloudformation troposphere

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

为AWS API Gateway生成swagger json定义

作为我们持续交付管道的一部分,我将部署AWS API Gateway API.

最简单的方法是使用Amazon API Gateway Importer,它可以从Swagger表示创建或更新Amazon API Gateway API.

AWS为Swagger提供API网关扩展.通过这些扩展,您可以在Swagger定义中提供请求/响应模板.下面是一个带有Swagger API网关扩展的json片段示例:

"x-amazon-apigateway-integration": {
      "responses": {
        "default": {
          "statusCode": "200",
          "responseParameters": {
            "method.response.header.Access-Control-Allow-Origin": "'*'"
          },
          "responseTemplates": {
            "application/json": "#set($inputRoot = $input.path('$'))\r\n[\r\n#foreach($elem in $inputRoot)\r\n    {\r\n      \"id\" : \"$elem.id\",\r\n      \"login\" : \"$elem.login\"\r\n    }#if($foreach.hasNext),#end\r\n        \r\n#end\r\n  ]\r\n"
          }
        }
      },
      "uri": "http://www.example.com/api/users",
      "httpMethod": "GET",
      "requestParameters": {
        "integration.request.querystring.page": "method.request.querystring.page",
        "integration.request.header.x-auth-token": "method.request.header.x-auth-token",
        "integration.request.querystring.size": "method.request.querystring.size"
      },
      "type": "http"
    }
  }
Run Code Online (Sandbox Code Playgroud)

编辑Swagger定义变得容易出错,因为您需要内联AWS API网关模板.

Swagger网站列出了许多用于从Swagger定义生成客户端/服务器存根或从API代码生成Swagger定义的工具.

我正在寻找类似于对流层的工具.我的想法是我可以用Python定义我的API,然后生成一个JSON或yaml文件.好处是我可以分离AWS API网关请求/响应模板,然后将它们拉入生成的Swagger定义中.

有谁知道任何有用的工具?

amazon-web-services swagger swagger-editor troposphere aws-api-gateway

6
推荐指数
0
解决办法
1655
查看次数

如何将 AWS 托管策略附加到 cloudformation 和对流层中的角色

在我的对流层代码中,我基本上想创建一个 sns 主题和一个 lambda 执行角色,我可以在其中附加一些来自 aws 的托管策略。但问题是我找不到一种方法来引用托管策略的 arn 名称。下面是我的代码,但我在这里复制并粘贴托管策略 json 文档。

还有更好的出路吗?

from troposphere import FindInMap, GetAtt, Join, Output, Template, Ref, ImportValue
from troposphere.sns import Topic
from troposphere.iam import Role, Policy


t = Template()

t.set_version("2010-09-09")

sns_topic = Topic(TopicName='IngestStateTopic', title='IngestStateTopic')

t.add_resource(sns_topic)

LambdaExecutionRole = t.add_resource(
    Role(
        "LambdaExecutionRole",
        Path="/",
        Policies=[
            Policy(PolicyName="CloudWatchLogsFullAccess",
                   PolicyDocument={
                       "Version":
                       "2012-10-17",
                       "Statement": [{
                           "Action": ["logs:*"],
                           "Effect": "Allow",
                           "Resource": "*"
                       }]
                   }),
            Policy(PolicyName="SnsReadOnlyAccess",
                   PolicyDocument={
                       "Version":
                       "2012-10-17",
                       "Statement": [{
                           "Effect":
                           "Allow",
                           "Action": ["sns:GetTopicAttributes", "sns:List*"],
                           "Resource":
                           "*"
                       }]
                   }),
            Policy(PolicyName="LambdaBasicExecutionRole-Test",
                   PolicyDocument={
    "Version": "2012-10-17", …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services python-3.x aws-cloudformation troposphere

3
推荐指数
1
解决办法
6173
查看次数

适用于 Lambda 的 AWS 计划事件规则在 CloudFormation 中不起作用

使用 CloudFormation(实际上,使用 Python 的对流层)将 AWS Lambda 配置为由规则触发时遇到问题->触发器作为计划事件源。这已经花费了我几天时间,任何帮助将不胜感激。

这是相关的 CF JSON 片段 -

        "DataloaderRetrier": {
        "Properties": {
            "Code": {
                "S3Bucket": "mycompanylabs-config",
                "S3Key": "v3/mycompany-component-loader-lambda-0.5.jar"
            },
            "FunctionName": "DataloaderRetriervitest27",
            "Handler": "mycompany.ScheduledEventHandler::handleRequest",
            "MemorySize": 320,
            "Role": "arn:aws:iam::166662328783:role/kinesis-lambda-role",
            "Runtime": "java8",
            "VpcConfig": {
                "SecurityGroupIds": [
                    "sg-2f1f6047"
                ],
                "SubnetIds": [
                    "subnet-ec3c1435"
                ]
            }
        },
        "Type": "AWS::Lambda::Function"
    },
    "DataloaderRetrierEventTriggerPermission": {
        "Properties": {
            "Action": "lambda:InvokeFunction",
            "FunctionName": {
                "Fn::GetAtt": [
                    "DataloaderRetrier",
                    "Arn"
                ]
            },
            "Principal": "events.amazonaws.com",
            "SourceAccount": {
                "Ref": "AWS::AccountId"
            },
            "SourceArn": {
                "Fn::GetAtt": [
                    "DataloaderRetrierEventTriggerRule",
                    "Arn"
                ]
            }
        },
        "Type": "AWS::Lambda::Permission" …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-cloudformation aws-lambda troposphere

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

如何创建一个由对流层的云观察事件定期调用的Lambda?

我创建了一个Lambda函数,我希望每隔5分钟调用一次,或者每天调用一次,或者其他什么.我如何用对流层进行设置?

我无法在任何地方找到一个例子.

aws-cloudformation amazon-cloudwatch aws-lambda troposphere

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