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