AWS Config(一)---S3

本文介绍了如何使用AWS Config进行S3配置,包括新建规则(cloudtrail-enabled, desired-instance-type, ec2-instances-in-vpc)、通过CloudFormation尝试创建配置、在S3启用版本控制、创建CloudTrail trail,以及重新评估规则以确保合规性。" 109004618,7865661,LeetCode刷题解析:访问点、井字棋、数字差、超25%数字与二进制链表,"['算法', '数据结构', '问题解决', '编程挑战', '逻辑思维']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

1. 在aws config页面,新建一个config

2. 新建rules

(1) 点击add rules,然后输入cloudtrail,接着选择cloudtrail-enabled

save保存

(2) 接着再 add rule,这次点击向右翻页的按钮,选择desired-instance-type

在下一页中输入value为t2.micro

save保存

(3) 参考步骤(2),接着add rule,这次选择ec2-instances-in-vpc,并在VPC页面拷贝vpc id过来填写

save保存

(4)参考步骤(2),继续创建一个rule,这次选择Select the s3-bucket-versioning-enabled card

3. 步骤1中创建config的方法,也可以换成cloudformation来实现(不过我没成功)

在cloudformation中新建stack,输入JSON代码如下

{
  "Resources": {
    "AWSConfigRule": {
      "Type": "AWS::Config::ConfigRule",
      "Properties": {
        "ConfigRuleName": {
          "Ref": "ConfigRuleName"
        },
        "Description": "Checks whether your EC2 instances are of the specified instance types.",
        "InputParameters": {
          "instanceType": {
            "Fn::If": [
              "instanceType",
              {
                "Ref": "instanceType"
              },
              {
                "Ref": "AWS::NoValue"
              }
            ]
          }
        },
        "Scope": {
          "ComplianceResourceTypes": [
            "AWS::EC2::Instance"
          ]
        },
        "Source": {
          "Owner": "AWS",
          "SourceIdentifier": "DESIRED_INSTANCE_TYPE"
        }
      }
    }
  },
  "Parameters": {
    "ConfigRuleName": {
      "Type": "String",
      "Default": "desired-instance-type",
      "Description": "The name that you assign to the AWS Config rule.",
      "MinLength": "1",
      "ConstraintDescription": "This parameter is required."
    },
    "instanceType": {
      "Type": "String",
      "Description": "Comma separated list of EC2 instance types (for example, \u0027t2.small, m4.large\u0027).",
      "MinLength": "1",
      "ConstraintDescription": "This parameter is required."
    }
  },
  "Metadata": {
    "AWS::CloudFormation::Interface": {
      "ParameterGroups": [
        {
          "Label": {
            "default": "Required"
          },
          "Parameters": [
            "instanceType"
          ]
        },
        {
          "Label": {
            "default": "Optional"
          },
          "Parameters": []
        }
      ]
    }
  },
  "Conditions": {
    "instanceType": {
      "Fn::Not": [
        {
          "Fn::Equals": [
            "",
            {
              "Ref": "instanceType"
            }
          ]
        }
      ]
    }
  }
}

页面最后一行中选择template,继续添加代码如下:

{
  "AWSTemplateFormatVersion" : "2010-09-09",

  "Description" : "AWS CloudFormation Sample Template EC2InstanceWithSecurityGroupSample: Create an Amazon EC2 instance running the Amazon Linux AMI. The AMI is chosen based on the region in which the stack is run. This example creates an EC2 security group for the instance to give you SSH access. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.",

  "Parameters" : {
    
    "myVPC": {
        "Description" : "Id of my VPC",
        "Type"        : "String",
        "Defaul
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值