## AWS Configの動作概要

### 設定単位
リージョン
### 主なコンポーネント
```
AWS::Config::ConfigurationRecorder
AWS::Config::DeliveryChannel
```
[https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/AWS_Config.html](https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/AWS_Config.html)
### 設定項目
- 記録するリソース
[https://docs.aws.amazon.com/ja_jp/config/latest/developerguide/select-resources.html](https://docs.aws.amazon.com/ja_jp/config/latest/developerguide/select-resources.html)
- このリージョンでサポートされる現在および今後のすべてのリソースタイプを記録(デフォルト)
- グローバルに記録されたリソースタイプを含める
- 現在および今後のすべてのリソースタイプを除外で記録する
- 特定のリソースタイプを記録する
- IAMロール
- 既存の AWS Config サービスにリンクされたロールを使用
- アカウントからロールを選択
```
ConfigRecorder:
Type: AWS::Config::ConfigurationRecorder
DependsOn:
- ConfigBucketPolicy
Properties:
RoleARN: !GetAtt ConfigRecorderRole.Arn
RecordingGroup:
AllSupported: !Ref AllSupported
IncludeGlobalResourceTypes: !Ref IncludeGlobalResourceTypes
ResourceTypes: !If
- IsAllSupported
- !Ref AWS::NoValue
- !Ref ResourceTypes
```
- S3バケット
[AWS Config 配信チャネルの Amazon S3 バケットのアクセス許可](https://docs.aws.amazon.com/ja_jp/config/latest/developerguide/s3-bucket-policy.html)
- 配信頻度(Allowed values: One_Hour | Six_Hours | Three_Hours | Twelve_Hours | TwentyFour_Hours)
- SNSトピック
```
ConfigDeliveryChannel:
Type: AWS::Config::DeliveryChannel
DependsOn:
- ConfigBucketPolicy
Properties:
Name: !If
- IsGeneratedDeliveryChannelName
- !Ref AWS::NoValue
- !Ref DeliveryChannelName
ConfigSnapshotDeliveryProperties:
DeliveryFrequency: !FindInMap
- Settings
- FrequencyMap
- !Ref Frequency
S3BucketName: !Ref ConfigBucket
SnsTopicARN: !If
- CreateTopic
- !Ref ConfigTopic
- !Ref TopicArn
```
- 配信チャネルの管理
[https://docs.aws.amazon.com/ja_jp/config/latest/developerguide/manage-delivery-channel.html](https://docs.aws.amazon.com/ja_jp/config/latest/developerguide/manage-delivery-channel.html)
- Config マネージドルールのリスト
[https://docs.aws.amazon.com/ja_jp/config/latest/developerguide/managed-rules-by-aws-config.html](https://docs.aws.amazon.com/ja_jp/config/latest/developerguide/managed-rules-by-aws-config.html)
- CloudFormationテンプレートを使用したConfigマネージドルールの作成
[https://docs.aws.amazon.com/ja_jp/config/latest/developerguide/aws-config-managed-rules-cloudformation-templates.html](https://docs.aws.amazon.com/ja_jp/config/latest/developerguide/aws-config-managed-rules-cloudformation-templates.html)
### AWS CloudFormation StackSets のサンプルテンプレート
[AWS CloudFormation StackSets のサンプルテンプレート](https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/stacksets-sampletemplates.html)
* AWS Config の有効化
* 中央ログで AWS Config を有効にする
### 設定確認方法
#### 現在のリージョン
```
aws configservice describe-delivery-channels
```
#### 全リージョン
```
aws ec2 describe-regions --region ap-northeast-1 --query "Regions[].[RegionName]" --output text \
| while read r; do
recorder=$(aws configservice describe-configuration-recorders --region $r \
--query "ConfigurationRecorders[].name" --output text)
echo "${r} ${recorder}"
done
```
#### 有効化されている全リージョンのConfigを無効化
> GUIの方には削除メニューがない
```
for r in `aws ec2 describe-regions --query Regions[*].RegionName --output text`
do
for channel_name in `aws configservice describe-delivery-channels --region $r --query DeliveryChannels[*].name --output text`
do
recorder_name=`aws configservice describe-configuration-recorders --region $r --query ConfigurationRecorders[*].name --output text`
aws configservice delete-configuration-recorder --configuration-recorder-name $recorder_name --region $r
aws configservice delete-delivery-channel --delivery-channel-name $channel_name --region $r
done
done
```
0 件のコメント:
コメントを投稿