标签: aws-cloudformation-custom-resource

通过 Cloud Formation 创建 Amazon Elasticsearch Service 时 CloudWatch 资源访问策略错误

我正在尝试创建一个启用了LogPublishingOptions. 虽然启用 LogPublishingOptions ES 表示它没有足够的权限在 Cloudwatch 上创建 LogStream。

我尝试创建一个带有角色的策略并将该策略附加到 ES 引用的 LogGroup,但它不起作用。以下是我的弹性搜索云形成模板,

AWSTemplateFormatVersion: 2010-09-09

Resources:
  MYLOGGROUP:
    Type: 'AWS::Logs::LogGroup'
    Properties:
      LogGroupName: index_slow

  MYESROLE:
    Type: 'AWS::IAM::Role'
    Properties:
      AssumeRolePolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal:
              Service: es.amazonaws.com
            Action: 'sts:AssumeRole'
      ManagedPolicyArns:
        - 'arn:aws:iam::aws:policy/AmazonESFullAccess'
        - 'arn:aws:iam::aws:policy/CloudWatchFullAccess'
      RoleName: !Join
        - '-'
        - - es
          - !Ref 'AWS::Region'

  PolicyDocESIndexSlow :
    Type: AWS::IAM::Policy
    Properties:
      PolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Action: 
             - logs:PutLogEvents
             - logs:CreateLogStream
            Resource: 'arn:aws:logs:*'
      PolicyName: !Ref MYLOGGROUP
      Roles:
        - !Ref MYESROLE …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services elasticsearch aws-cloudformation amazon-iam aws-cloudformation-custom-resource

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

如何在我的新 CloudFormation 模板中引用现有角色?

在我的 AWS 账户中,我正在构建一个用于创建新策略的新 Cloudformation 模板,我想将这些模板附加到账户中的一些现有角色。这是我一直试图引用它们的方式:

{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "Names of existing roles to which the restrictive policies need added",
    "Parameters": {
        "AdditionalExecutionRoleParameter": {
            "Type": "AWS::IAM::Role",
            "Default": "CloudOps"
        }
    },
    "Resources": { (and so on)
Run Code Online (Sandbox Code Playgroud)

然后在新策略下方的部分中,我一直在尝试引用这些现有角色(在本例中为“AdditionalExecutionRoleParameter”)并使用 Roles 参数将策略附加到它们。但是,在尝试部署 CloudFormation 模板时,我不断收到“无法检索外部值”错误......我尝试输入角色名称“CloudOps”作为参数“默认”,并且我已经还尝试在那里输入角色 ARN...没有任何效果。

amazon-web-services aws-cloudformation aws-cloudformation-custom-resource

4
推荐指数
2
解决办法
4468
查看次数

有没有办法禁用 CDK 堆栈上的自动回滚

我们正在使用触发 lambda 的 cdk 在堆栈中创建 aws 自定义资源。在我们的例子中,如果 lambda 中发生任何故障,它会向自定义资源发送故障信号,并且自定义资源会触发自动回滚到堆栈的先前版本。我们想要阻止这种情况发生。我们的要求是,如果 lambda 失败,自定义资源堆栈仅显示失败状态并且不会触发任何回滚部署。

有没有办法使用 cdk 在堆栈上设置禁用回滚属性

amazon-web-services aws-cdk aws-cloudformation-custom-resource aws-cdk-custom-resource

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

Terraform AWS 安全组自我参考

我正在使用 terraform 进行 AWS 资源配置。我需要自我参考“mySG”。从 Terraform 文档我可以使用

 ingress {
          from_port = 0
          to_port = 0
          protocol = -1
          self = true
      }
Run Code Online (Sandbox Code Playgroud)

但是不同的协议呢?使用控制台 有以下历史入站规则可用:

      Type      Protocol         PortRange      Source
1. All TCP      TCP             0-65535         mySG 
2. All UDP       UDP              0-65535         mySG 
3. Custom TCP    TCP             1856            mySG
Run Code Online (Sandbox Code Playgroud)

(是否需要第三个条目?考虑所有端口的第一个条目)上述入口规则是否处理所有 3 个条目?如果不是什么应该是 terraform 语法。

amazon-web-services aws-cli aws-security-group terraform-provider-aws aws-cloudformation-custom-resource

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

AWS SAM 模板中出现 Fn::GetAtt 错误

我已在我的 AWS 无服务器应用程序模型模板中声明了 SNS 主题和订阅,如下所示:-

MyTopic:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName: !Sub 'test-${Environment}-${AWS::AccountId}-${AWS::Region}'
      Tags:
       - Key: Environment
         Value: !FindInMap [Environment, FullForm, !Ref Environment]
      TopicName: !Sub 'test-${Environment}-${AWS::AccountId}-${AWS::Region}'

  MySubscription:
    Type: AWS::SNS::Subscription
    Properties:
      Endpoint: !Ref SubscriptionEndPoint
      Protocol: !Ref SubscriptionProtocol
      Region: !Ref 'AWS::Region'
      TopicArn: !Ref MyTopic
Run Code Online (Sandbox Code Playgroud)

然后在我的 Lambda 函数环境中使用 SNS 主题 ARN,如下所示在同一模板文件中:-

MyLambda:
    Type: AWS::Serverless::Function
    Properties:
      Environment:
        Variables:
          RUNTIME_SNS_TOPIC_ARN: !GetAtt MyTopic.Arn
Run Code Online (Sandbox Code Playgroud)

输出(在 SAM 模板中):-

MyTopic:
    Description: SNS Topic for the Ingest to send notification to
    Export:
      Name: !Sub
        - ${ExportPrefix_}:${AWS::Region}:MyTopic
        - ExportPrefix_: !If
          - HasExportPrefix …
Run Code Online (Sandbox Code Playgroud)

aws-cloudformation aws-sam aws-cloudformation-custom-resource

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

使用 CloudFormation 复制现有 AWS 资源

我有在浏览器中手动创建的 AWS 资源

现在我希望能够使用 CloudFormation 创建等效资源。是否有一种工具可以将现有的 AWS 资源转换为 cloudformation 模板,并使用其所有当前属性来创建它?

例如,我有一个带有许多附加策略的 IAM 角色。我想要一个功能齐全的 CloudFormation 模板来复制它。

这可能吗?

另一种方法是浏览 CloudFormation IAM 角色文档并查看所有选项,并在控制台上手动检查这些属性,并通过反复试验来复制它们。

我尝试使用现有资源在 CloudFormation 中创建一个堆栈,但它需要一个模板...我没有模板,我想创建一个。我也尝试使用设计器创建一个堆栈,但我找不到可以选择导入现有资源

amazon-web-services aws-cloudformation aws-cloudformation-custom-resource

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

我们可以通过 AWS Cloudformation 动态创建 Keypair 并将 .PEM 文件复制到 EC2 Linux 实例吗

我的要求是创建一个 EC2 实例,该实例将从相同的 Cloudformation 模板动态创建密钥对。截至目前,我正在从 AWS 控制台创建密钥对,并通过获取用户的输入通过 Cloudformation 将其分配给 EC2 实例。

我检查了 AWS 文档,发现可以从 AWS 控制台创建 KeyPair。

是否可以通过 Cloudformation 创建密钥对并在实例中复制 .PEM 文件。

amazon-ec2 amazon-web-services aws-cloudformation aws-cloudformation-custom-resource

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

按照模板中提到的顺序排列参数

当您在控制台中创建堆栈时,控制台会按输入参数的逻辑 ID 按字母顺序列出输入参数。有一种方法可以使用界面自定义订单。

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-interface.html

但是有什么办法可以按照模板中提到的参数来排序吗?

aws-cloudformation aws-cloudformation-custom-resource

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

将ECS服务转换为cloudformation

我正在尝试将手动创建的服务转换为 cloudformation 模板,但我不断收到错误。

任务定义已使用 UI 创建,因为它需要一些特定角色

这个模板给了我:Classic Load Balancers are not supported with Fargate

  ServicesSG:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: Security group for cluster services
      VpcId: !Ref 'VPC'
      SecurityGroupIngress:
        - IpProtocol: tcp
          FromPort: 0
          ToPort: 65535
          SourceSecurityGroupId: !Ref "PublicLoadBalancerSG"

  ServiceStaging:
    Type: AWS::ECS::Service
    Properties:
      ServiceName: pouch-svc-staging
      TaskDefinition: pouch-td-staging:4
      Cluster: !Ref 'ClusterECS'
      DesiredCount: 2
      SchedulingStrategy: REPLICA
      LaunchType: FARGATE
      EnableECSManagedTags: true
      DeploymentConfiguration:
        MinimumHealthyPercent: 100
        MaximumPercent: 200
        DeploymentCircuitBreaker:
          Enable: false
          Rollback: false
      NetworkConfiguration:
        AwsvpcConfiguration:
          AssignPublicIp: ENABLED
          Subnets:
            - !Ref PublicSubnetOne
            - !Ref PublicSubnetTwo
          SecurityGroups: …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services amazon-ecs aws-cloudformation aws-fargate aws-cloudformation-custom-resource

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

CloudFormation 模板不选择密钥对

我使用以下方法成功创建了以下四个资源Cloud Formation Template (CFT)

  1. 专有网络
  2. 子网
  3. 互联网网关
  4. 连接网关

现在,我正在尝试使用 EC2 实例创建一个安全组,这是代码。

  Type: AWS::EC2::SecurityGroup
  Properties:
      GroupDescription: Allow http and ssh to client host
      VpcId:
         Ref: InsuranceVPC
      SecurityGroupIngress:
      - IpProtocol: tcp
        FromPort: 80
        ToPort: 80
        CidrIp: 0.0.0.0/0
      - IpProtocol: tcp
        FromPort: 22
        ToPort: 22
        CidrIp: 0.0.0.0/0
      SecurityGroupEgress:
      - IpProtocol: tcp
        FromPort: 80
        ToPort: 80
        CidrIp: 0.0.0.0/0

Ec2Instance: 
  Type: AWS::EC2::Instance
  Properties: 
    ImageId: "ami-08706cb5f68222d09"
    KeyName: 
      Ref: "DevOpsAutomation"
    NetworkInterfaces: 
      - AssociatePublicIpAddress: "true"
        DeviceIndex: "0"
        GroupSet: 
          - Ref: "InsuranceSecurityGroup"
        SubnetId: 
          Ref: "InsuranceSubnet"
Run Code Online (Sandbox Code Playgroud)

但是,当我在(CFT,如上所示,代码)中使用 Key …

amazon-ec2 amazon-web-services aws-cloudformation aws-cloudformation-custom-resource

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

参数值在 aws cli Cloudformation 中不起作用

我正在通过 AWS CLI 运行我的云形成模板。它工作正常并在 AWS 门户上创建堆栈,但我面临一个问题,即无法更改默认参数值。我使用 CLI 传递我自己的参数,但只有最后一个参数值从堆栈中发生变化(即 30),其余的没有变化,而是从模板主体中选择默认值。我已经通过更改参数的位置尝试了所有可能的方法,但它仍然相同。所以请让我知道我将如何解决这个恼人的问题。这是我的命令:-

aws --region eu-north-1 cloudformation  create-stack --stack-name cli4  --template-body file://app_cli.json --parameters "ParameterKey"="Maxvalue","ParameterValue"="7","ParameterKey"="increment","ParameterValue"="1","ParameterKey"="incrementtime","ParameterValue"="30"

"Parameters": {
        "EnvironmentName": {
            "Description": "An environment name that will be prefixed to resource names",
            "Type": "String",
            "Default": "Codavel"
        },
        "amiID": {
        "Description": "Put ami-id in this",
        "Type": "String",
        "Default": "ami-085045326daf7e309"
        },
        "Maxvalue": {
        "Description": "Put max value in this",
        "Type": "String",
        "Default": "100"
        },
        "increment": {
        "Description": "Put No. of incremental instance this",
        "Type": "String",
        "Default": "2"
        },
        "incrementtime": …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-cloudformation aws-cli devops aws-cloudformation-custom-resource

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