
Standalone版のBLEAでデプロイされるリソースをパラメータシートに起こしてみた
2025.02.03
こんにちは、こーへいです。
今回はStandalon版のBLEAでデプロイされるリソースをパラメータシートとして起こしてみたのでご活用ください。
BLEAの概要的な説明は以下記事をご参照ください。
Detection
GuardDuty
有効化のみ
Security Hub
有効化のみ
※セキュリティ基準は、「AWS 基礎セキュリティのベストプラクティス v1.0.0」と「CIS AWS Foundations Benchmark v1.2.0」を利用
SNS
トピック
トピック名 | タイプ | アクセスポリシー | 備考 |
---|---|---|---|
DetectionAlarmTopic | スタンダード | 下記記載 |
サブスクリプション
プロトコル | エンドポイント | 備考 |
---|---|---|
HTTPS | AWS Chatbot(パラメータファイルで指定) | Chatbot経由にてSlack等へ通知可能 |
パラメータファイルで指定 | 登録したメールへ通知可能 |
トピックポリシー
CloudWatchやEventBridgeからのアクセス権限を許可
{
"Statement": [
{
"Action": "sns:Publish",
"Effect": "Allow",
"Principal": {
"Service": "cloudwatch.amazonaws.com"
},
"Resource": {
"Ref": "DetectionAlarmTopicxxxxxxxx"
},
"Sid": "0"
},
{
"Action": "sns:Publish",
"Effect": "Allow",
"Principal": {
"Service": "events.amazonaws.com"
},
"Resource": {
"Ref": "DetectionAlarmTopicxxxxxxxx"
},
"Sid": "1"
}
],
"Version": "2012-10-17"
}
CloudWatch
アラーム
アラーム名 | 名前空間 | メトリクス名 | 統計 | 期間 | 閾値 | 通知先SNSトピック | 説明 |
---|---|---|---|---|---|---|---|
DetectionIAMPolicyChangeAlarm | CloudTrailMetrics | IAMPolicyEventCount | 合計 | 5分 | 1回以上 | DetectionAlarmTopic | IAMポリシーを変更するためのAPI呼び出しが行われたときに通知 |
DetectionNewAccessKeyCreatedAlarm | CloudTrailMetrics | NewAccessKeyCreatedEventCount | 合計 | 5分 | 1回以上 | DetectionAlarmTopic | IAMユーザのアクセスキーが作成された際に通知 |
DetectionRootUserActivityAlarm | CloudTrailMetrics | RootUserPolicyEventCount | 合計 | 5分 | 1回以上 | DetectionAlarmTopic | Rootユーザにより操作が行われた際に通知 |
DetectionUnauthorizedAttemptsAlarm | CloudTrailMetrics | UnauthorizedAttemptsEventCount | 300 | 合計 | 5回以上 | DetectionAlarmTopic | AWS環境でのアクセス拒否エラーが5回以上発生した際に通知 |
メトリクスフィルター
- メトリクスフィルターとはログデータから特定の文字列のフィルタリングをする機能で、CloudWatch Logs に取り込まれたログデータの中から、監視対象のデータを抽出してメトリクスとして数値化、可視化が可能な機能(参考)
- こちらでメトリクスしたものを、上記のCaloudWatch Alarmで監視している
フィルター名 | 対象ロググループ | イベントパターン | メトリクス名前空間 | メトリクス名 | メトリクス値 | 備考 |
---|---|---|---|---|---|---|
DetectionIAMPolicyChangeFilter | LoggingCloudTrailLogGroup | 下記記載 | CloudTrailMetrics | IAMPolicyEventCount | 1 | CloudWatch Alarm「DetectionIAMPolicyChangeAlarm」用のメトリクスフィルター |
DetectionNewAccessKeyCreatedFilter | LoggingCloudTrailLogGroup | {($.eventName=CreateAccessKey)} | CloudTrailMetrics | NewAccessKeyCreatedEventCount | 1 | CloudWatch Alarm「DetectionNewAccessKeyCreatedAlarm」用のメトリクスフィルター |
DetectionRootUserActivityFilter | LoggingCloudTrailLogGroup | {$.userIdentity.type="Root" && $.userIdentity.invokedBy NOT EXISTS && $.eventType !="AwsServiceEvent"} | CloudTrailMetrics | RootUserPolicyEventCount | 1 | CloudWatch Alarm「DetectionRootUserActivityAlarm」用のメトリクスフィルター |
DetectionUnauthorizedAttemptsFilter | LoggingCloudTrailLogGroup | 下記記載 | CloudTrailMetrics | UnauthorizedAttemptsEventCount | 1 | CloudWatch Alarm「DetectionUnauthorizedAttemptsAlarm」用のメトリクスフィルター |
フィルターパターン
DetectionIAMPolicyChangeFilter
{($.eventName=DeleteGroupPolicy)||($.eventName=DeleteRolePolicy)||($.eventName=DeleteUserPolicy)||($.eventName=PutGroupPolicy)||($.eventName=PutRolePolicy)||($.eventName=PutUserPolicy)||($.eventName=CreatePolicy)||($.eventName=DeletePolicy)||($.eventName=CreatePolicyVersion)||($.eventName=DeletePolicyVersion)||($.eventName=AttachRolePolicy)||($.eventName=DetachRolePolicy)||($.eventName=AttachUserPolicy)||($.eventName=DetachUserPolicy)||($.eventName=AttachGroupPolicy)||($.eventName=DetachGroupPolicy)}
DetectionUnauthorizedAttemptsFilter
{(\$.errorCode = "*UnauthorizedOperation" \|\| \$.errorCode = "AccessDenied*") && (\$.eventName != "Decrypt" \|\| \$.userIdentity.invokedBy != "config.amazonaws.com" )}
Configのデフォルトセキュリティグループのインバウンド(アウトバウンド)ルール削除の関連リソース
Configルール
ルール | 概要 | 対象リソースタイプ | インプットパラメータ | 備考 |
---|---|---|---|---|
bb-default-security-group-closed | デフォルトのセキュリティグループが、インバウンドまたはアウトバウンドのトラフィックを許可していないことをチェック | AWS::EC2::SecurityGroup | 修復アクションあり |
Configルールの修復アクション
対象Configルール | アクションの種類 | リトライ回数(時間枠) | パラメータ | 修復アクション(タイプ) | 備考 |
---|---|---|---|---|---|
bb-default-security-group-closed | 自動修復 | 5(60) | AutomationAssumeRole:DetectionDefaultSgRemediationRole(修復アクションを実行するルール) GroupId:RESOURCE_ID(修復対象のデフォルトのセキュリティグループのID) |
AWSConfigRemediation-RemoveVPCDefaultSecurityGroupRules(SSM_DOCUMENT) | デフォルトセキュリティグループからすべてのインバウンドおよびアウトバウンドルールを削除するアクション |
IAMロール
ロール | 信頼されたエンティティ | 付与ポリシー | 備考 |
---|---|---|---|
DetectionDefaultSgRemediationRole | ssm | AmazonSSMAutomationRole DetectionDefaultSgRemediationRoleDefaultPolicy |
Config自動修復アクション用Role |
IAMポリシー
ポリシー名 | ポリシー | アタッチ先 | 備考 |
---|---|---|---|
DetectionDefaultSgRemediationRoleDefaultPolicy | 下記記載 | DetectionDefaultSgRemediationRole | DetectionDefaultSgRemediationRoleにアタッチするポリシー |
ポリシー
{
"Statement": [
{
"Action": [
"ec2:RevokeSecurityGroupIngress",
"ec2:RevokeSecurityGroupEgress",
"ec2:DescribeSecurityGroups"
],
"Effect": "Allow",
"Resource": "*"
},
{
"Action": "iam:PassRole",
"Effect": "Allow",
"Resource": {
"Fn::GetAtt": [
"DetectionDefaultSgRemediationRolexxxxxxxx",
"Arn"
]
}
},
{
"Action": "ssm:StartAutomationExecution",
"Effect": "Allow",
"Resource": "arn:aws:ssm:::automation-definition/AWSConfigRemediation-RemoveVPCDefaultSecurityGroupRules"
}
],
"Version": "2012-10-17"
}
EventBridge
ルール一覧
ルール | イベントパターン | イベントバス | ターゲット | 備考 |
---|---|---|---|---|
DetectionAwsHealthEventRule | 下記記載 | default | DetectionAlarmTopic | AWS Healthでイベントの発生をトリガーに通知 |
DetectionCloudTrailChangeEventRule | 下記記載 | default | DetectionAlarmTopic | CloudTrailのログ設定変更をトリガーに通知 |
DetectionDefaultSgClosedEventRule | 下記記載 | default | DetectionAlarmTopic | Configルール「bb-default-security-group-closed」の非準拠検知をトリガーに通知 |
DetectionGuardDutyEventRule | 下記記載 | default | DetectionAlarmTopic | GuardDutyにて重大度レベルが4以上の検知をトリガーに通知 |
DetectionNetworkAclChangeEventRule | 下記記載 | default | DetectionAlarmTopic | NACLの作成、変更、削除などのイベントをトリガーに通知 |
DetectionSecurityHubEventRule | 下記記載 | default | DetectionAlarmTopic | Security Hubにて重大度レベルが「HIGH」「CRITICAL」の検知をトリガーに通知 |
DetectionSgChangedEventRule | 下記記載 | default | DetectionAlarmTopic | セキュリティグループのトラフィックルールの変更をトリガーに通知 |
イベントパターン
DetectionAwsHealthEventRule
{
"source": [
"aws.health"
],
"detail-type": [
"AWS Health Event"
]
}
DetectionCloudTrailChangeEventRule
{
"detail-type": [
"AWS API Call via CloudTrail"
],
"detail": {
"eventSource": [
"cloudtrail.amazonaws.com"
],
"eventName": [
"StopLogging",
"DeleteTrail",
"UpdateTrail"
]
}
}
DetectionDefaultSgClosedEventRule
{
"source": [
"aws.config"
],
"detail-type": [
"Config Rules Compliance Change"
],
"detail": {
"configRuleName": [
"bb-default-security-group-closed"
],
"newEvaluationResult": {
"complianceType": [
"NON_COMPLIANT"
]
}
}
}
DetectionGuardDutyEventRule
{
"source": [
"aws.guardduty"
],
"detail-type": [
"GuardDuty Finding"
],
"detail": {
"severity": [
4,
4,
4.1,
4.2,
4.3,
4.4,
4.5,
4.6,
4.7,
4.8,
4.9,
5,
5,
5.1,
5.2,
5.3,
5.4,
5.5,
5.6,
5.7,
5.8,
5.9,
6,
6,
6.1,
6.2,
6.3,
6.4,
6.5,
6.6,
6.7,
6.8,
6.9,
7,
7,
7.1,
7.2,
7.3,
7.4,
7.5,
7.6,
7.7,
7.8,
7.9,
8,
8,
8.1,
8.2,
8.3,
8.4,
8.5,
8.6,
8.7,
8.8,
8.9
]
}
}
DetectionNetworkAclChangeEventRule
{
"source": [
"aws.ec2"
],
"detail-type": [
"AWS API Call via CloudTrail"
],
"detail": {
"eventSource": [
"ec2.amazonaws.com"
],
"eventName": [
"CreateNetworkAcl",
"CreateNetworkAclEntry",
"DeleteNetworkAcl",
"DeleteNetworkAclEntry",
"ReplaceNetworkAclEntry",
"ReplaceNetworkAclAssociation"
]
}
}
DetectionSecurityHubEventRule
{
"source": [
"aws.securityhub"
],
"detail-type": [
"Security Hub Findings - Imported"
],
"detail": {
"findings": {
"Severity": {
"Label": [
"CRITICAL",
"HIGH"
]
},
"Compliance": {
"Status": [
"FAILED"
]
},
"Workflow": {
"Status": [
"NEW",
"NOTIFIED"
]
},
"RecordState": [
"ACTIVE"
]
}
}
}
DetectionSgChangedEventRule
{
"source": [
"aws.ec2"
],
"detail-type": [
"AWS API Call via CloudTrail"
],
"detail": {
"eventSource": [
"ec2.amazonaws.com"
],
"eventName": [
"AuthorizeSecurityGroupIngress",
"AuthorizeSecurityGroupEgress",
"RevokeSecurityGroupIngress",
"RevokeSecurityGroupEgress"
]
}
}
Detection(Config Conformance Pack)
Configルール
ルール名 | 概要 | 対象リソースタイプ | インプットパラメータ | 備考 |
---|---|---|---|---|
CheckForEbsOptimizedInstance | EBS最適化されたEC2インスタンスを起動したかのチェック | AWS::EC2::Instance | ||
CheckForEc2VolumesInUse | EC2インスタンスにアタッチされていないEBSがないかのチェック | AWS::EC2::Volume | deleteOnTermination:true | |
CheckForEncryptedVolumes | アタッチされた状態のEBSが暗号化されているかのチェック | AWS::EC2::Volume | ||
CheckForIAMUserConsoleMFA | コンソールパスワードを有効化しているIAMユーザーにMFAが有効化されているかのチェック | 1時間毎にチェックが走る | ||
CheckForIAMUserMFA | IAMユーザーにMFAが有効化されているかのチェック | 1時間毎にチェックが走る | ||
CheckForPublicRdsSnapshots | RDSのパブリックスナップショットが存在するかのチェック | AWS::RDS::DBSnapshot | ||
CheckForRdsPublicAccess | RDSがパブリックアクセス可能かのチェック | AWS::RDS::DBInstance | ||
CheckForRdsStorageEncryption | RDSのストレージ暗号化が有効になっているかのチェック | AWS::RDS::DBInstance | ||
CheckForRestrictedCommonPortsPolicy | 使用中のセキュリティグループが指定されたポートへの無制限の受信TCPトラフィックを公開しているかのチェック | AWS::EC2::SecurityGroup | 下記記載 | |
CheckForRestrictedSshPolicy | 使用中のセキュリティグループが無制限の受信SSHトラフィックを公開しているかのチェック | AWS::EC2::SecurityGroup | ||
CheckForRootMfa | rootユーザーがコンソールへのサインインに多要素認証を必要とするかどうかのチェック | 1時間毎にチェックが走る | ||
CheckForS3PublicRead | S3バケットがパブリック読み取りアクセスを許可していないかのチェック | AWS::S3::Bucket | ||
CheckForS3PublicWrite | S3バケットがパブリック書き込みアクセスを許可していないかのチェック | AWS::S3::Bucket | ||
CheckForS3VersioningEnabled | S3バケットに対してバージョニングが有効かどうかのチェック | AWS::S3::Bucket |
CheckForRestrictedCommonPortsPolicyのインプットパラメータ
{
"blockedPort1": 20,
"blockedPort2": 21,
"blockedPort3": 3389,
"blockedPort4": 3306,
"blockedPort5": 4333
}
IAM
各ポリシー概要
IamAdmin
- IAMアクションを実行する際には、多要素認証が必須
- 課金や請求、コスト管理に関する広範な操作の拒否
InstanceOps
- EC2、ELB、CloudWatch、Auto Scalingに関する一般的なアクションの許可
- VPC、サブネット、ルートテーブル、VPN、ネットワークACLなどのVPC関連のリソースの作成、削除、変更の拒否
- 課金や請求、コスト管理に関する広範な操作の拒否
- KMSキーの作成、有効化、取得、無効化、削除、更新などのアクションの拒否
ReadOnlyAdmin
- さまざまなAWSサービスの読み取り専用の操作を許可
- 課金や請求、コスト管理に関する広範な操作の拒否
SysAdmin
- IAMアクションを実行する際には、多要素認証が必須
- 課金や請求、コスト管理に関する広範な操作の拒否
- CloudTrailの削除、ログの停止、更新の拒否
- KMSキーの作成、有効化、取得、無効化、削除、更新などのアクションの拒否
IAMグループ
グループ名 | ポリシー | 備考 |
---|---|---|
IamIamAdminGroup | IamIamAdminPolicy | |
IamInstanceOpsGroup | IamInstanceOpsPolicy | |
IamReadOnlyAdminGroup | IamReadOnlyAdminPolicy | |
IamSysAdminGroup | IamSysAdminPolicy |
IAMロール
ロール名 | 信頼されたエンティティ | ポリシー | 備考 |
---|---|---|---|
IamIamAdminRole | ec2 | IamIamAdminPolicy | |
IamInstanceOpsRole | ec2 | IamInstanceOpsPolicy | |
IamReadOnlyAdminRole | ec2 | IamReadOnlyAdminPolicy | |
IamSysAdminRole | ec2 | IamSysAdminPolicy |
IAMポリシー
IamIamAdminPolicy
{
"Statement": [
{
"Action": "iam:",
"Condition": {
"Bool": {
"aws:MultiFactorAuthPresent": "true"
}
},
"Effect": "Allow",
"Resource": ""
},
{
"Action": "aws-portal:Billing",
"Effect": "Deny",
"Resource": ""
},
{
"Action": [
"account:GetAccountInformation",
"billing:GetBillingData",
"billing:GetBillingDetails",
"billing:GetBillingNotifications",
"billing:GetBillingPreferences",
"billing:GetContractInformation",
"billing:GetCredits",
"billing:GetIAMAccessPreference",
"billing:GetSellerOfRecord",
"billing:ListBillingViews",
"billing:PutContractInformation",
"billing:RedeemCredits",
"billing:UpdateBillingPreferences",
"ce:CreateAnomalyMonitor",
"ce:CreateAnomalySubscription",
"ce:CreateNotificationSubscription",
"ce:CreateReport",
"ce:DeleteAnomalyMonitor",
"ce:DeleteAnomalySubscription",
"ce:DeleteNotificationSubscription",
"ce:DeleteReport",
"ce:DescribeNotificationSubscription",
"ce:DescribeReport",
"ce:GetAnomalies",
"ce:GetAnomalyMonitors",
"ce:GetAnomalySubscriptions",
"ce:GetCostAndUsage",
"ce:GetCostAndUsageWithResources",
"ce:GetCostCategories",
"ce:GetCostForecast",
"ce:GetDimensionValues",
"ce:GetPreferences",
"ce:GetReservationCoverage",
"ce:GetReservationPurchaseRecommendation",
"ce:GetReservationUtilization",
"ce:GetRightsizingRecommendation",
"ce:GetSavingsPlansCoverage",
"ce:GetSavingsPlansPurchaseRecommendation",
"ce:GetSavingsPlansUtilization",
"ce:GetSavingsPlansUtilizationDetails",
"ce:GetTags",
"ce:GetUsageForecast",
"ce:ListCostAllocationTags",
"ce:ListSavingsPlansPurchaseRecommendationGeneration",
"ce:ProvideAnomalyFeedback",
"ce:StartSavingsPlansPurchaseRecommendationGeneration",
"ce:UpdateAnomalyMonitor",
"ce:UpdateAnomalySubscription",
"ce:UpdateCostAllocationTagsStatus",
"ce:UpdateNotificationSubscription",
"ce:UpdatePreferences",
"consolidatedbilling:GetAccountBillingRole",
"consolidatedbilling:ListLinkedAccounts",
"cur:GetClassicReport",
"cur:GetClassicReportPreferences",
"cur:PutClassicReportPreferences",
"cur:ValidateReportDestination",
"freetier:GetFreeTierAlertPreference",
"freetier:GetFreeTierUsage",
"freetier:PutFreeTierAlertPreference",
"invoicing:GetInvoiceEmailDeliveryPreferences",
"invoicing:GetInvoicePDF",
"invoicing:ListInvoiceSummaries",
"invoicing:PutInvoiceEmailDeliveryPreferences",
"payments:CreatePaymentInstrument",
"payments:DeletePaymentInstrument",
"payments:GetPaymentInstrument",
"payments:GetPaymentStatus",
"payments:ListPaymentPreferences",
"payments:MakePayment",
"payments:UpdatePaymentPreferences",
"tax:BatchPutTaxRegistration",
"tax:DeleteTaxRegistration",
"tax:GetTaxInheritance",
"tax:GetTaxRegistrationDocument",
"tax:ListTaxRegistrations",
"tax:PutTaxInheritance"
],
"Effect": "Deny",
"Resource": "*"
}
],
"Version": "2012-10-17"
}
IamInstanceOpsPolicy
{
"Statement": [
{
"Action": "ec2:",
"Effect": "Allow",
"Resource": ""
},
{
"Action": "elasticloadbalancing:",
"Effect": "Allow",
"Resource": ""
},
{
"Action": "cloudwatch:",
"Effect": "Allow",
"Resource": ""
},
{
"Action": "autoscaling:",
"Effect": "Allow",
"Resource": ""
},
{
"Action": [
"ec2:CreateVpc*",
"ec2:DeleteVpc*",
"ec2:ModifyVpc*",
"ec2:CreateSubnet*",
"ec2:DeleteSubnet*",
"ec2:ModifySubnet*",
"ec2:CreateRoute",
"ec2:DeleteRoute*",
"ec2:AssociateRoute*",
"ec2:ReplaceRoute*",
"ec2:CreateVpn*",
"ec2:DeleteVpn*",
"ec2:AttachVpn*",
"ec2:DetachVpn*",
"ec2:CreateNetworkAcl*",
"ec2:DeleteNetworkAcl*",
"ec2:ReplaceNetworkAcl*",
"ec2:Gateway",
"ec2:PeeringConnection"
],
"Effect": "Deny",
"Resource": ""
},
{
"Action": "aws-portal:Billing",
"Effect": "Deny",
"Resource": ""
},
{
"Action": [
"account:GetAccountInformation",
"billing:GetBillingData",
"billing:GetBillingDetails",
"billing:GetBillingNotifications",
"billing:GetBillingPreferences",
"billing:GetContractInformation",
"billing:GetCredits",
"billing:GetIAMAccessPreference",
"billing:GetSellerOfRecord",
"billing:ListBillingViews",
"billing:PutContractInformation",
"billing:RedeemCredits",
"billing:UpdateBillingPreferences",
"ce:CreateAnomalyMonitor",
"ce:CreateAnomalySubscription",
"ce:CreateNotificationSubscription",
"ce:CreateReport",
"ce:DeleteAnomalyMonitor",
"ce:DeleteAnomalySubscription",
"ce:DeleteNotificationSubscription",
"ce:DeleteReport",
"ce:DescribeNotificationSubscription",
"ce:DescribeReport",
"ce:GetAnomalies",
"ce:GetAnomalyMonitors",
"ce:GetAnomalySubscriptions",
"ce:GetCostAndUsage",
"ce:GetCostAndUsageWithResources",
"ce:GetCostCategories",
"ce:GetCostForecast",
"ce:GetDimensionValues",
"ce:GetPreferences",
"ce:GetReservationCoverage",
"ce:GetReservationPurchaseRecommendation",
"ce:GetReservationUtilization",
"ce:GetRightsizingRecommendation",
"ce:GetSavingsPlansCoverage",
"ce:GetSavingsPlansPurchaseRecommendation",
"ce:GetSavingsPlansUtilization",
"ce:GetSavingsPlansUtilizationDetails",
"ce:GetTags",
"ce:GetUsageForecast",
"ce:ListCostAllocationTags",
"ce:ListSavingsPlansPurchaseRecommendationGeneration",
"ce:ProvideAnomalyFeedback",
"ce:StartSavingsPlansPurchaseRecommendationGeneration",
"ce:UpdateAnomalyMonitor",
"ce:UpdateAnomalySubscription",
"ce:UpdateCostAllocationTagsStatus",
"ce:UpdateNotificationSubscription",
"ce:UpdatePreferences",
"consolidatedbilling:GetAccountBillingRole",
"consolidatedbilling:ListLinkedAccounts",
"cur:GetClassicReport",
"cur:GetClassicReportPreferences",
"cur:PutClassicReportPreferences",
"cur:ValidateReportDestination",
"freetier:GetFreeTierAlertPreference",
"freetier:GetFreeTierUsage",
"freetier:PutFreeTierAlertPreference",
"invoicing:GetInvoiceEmailDeliveryPreferences",
"invoicing:GetInvoicePDF",
"invoicing:ListInvoiceSummaries",
"invoicing:PutInvoiceEmailDeliveryPreferences",
"payments:CreatePaymentInstrument",
"payments:DeletePaymentInstrument",
"payments:GetPaymentInstrument",
"payments:GetPaymentStatus",
"payments:ListPaymentPreferences",
"payments:MakePayment",
"payments:UpdatePaymentPreferences",
"tax:BatchPutTaxRegistration",
"tax:DeleteTaxRegistration",
"tax:GetTaxInheritance",
"tax:GetTaxRegistrationDocument",
"tax:ListTaxRegistrations",
"tax:PutTaxInheritance"
],
"Effect": "Deny",
"Resource": ""
},
{
"Action": [
"kms:Create*",
"kms:Revoke*",
"kms:Enable*",
"kms:Get*",
"kms:Disable*",
"kms:Delete*",
"kms:Put*",
"kms:Update*"
],
"Effect": "Deny",
"Resource": "*"
}
],
"Version": "2012-10-17"
}
IamReadOnlyAdminPolicy
{
"Statement": [
{
"Action": [
"appstream:Get*",
"autoscaling:Describe*",
"cloudformation:DescribeStacks",
"cloudformation:DescribeStackEvents",
"cloudformation:DescribeStackResource",
"cloudformation:DescribeStackResources",
"cloudformation:GetTemplate",
"cloudformation:List*",
"cloudfront:Get*",
"cloudfront:List*",
"cloudtrail:DescribeTrails",
"cloudtrail:GetTrailStatus",
"cloudwatch:Describe*",
"cloudwatch:Get*",
"cloudwatch:List*",
"directconnect:Describe*",
"dynamodb:GetItem",
"dynamodb:BatchGetItem",
"dynamodb:Query",
"dynamodb:Scan",
"dynamodb:DescribeTable",
"dynamodb:ListTables",
"ec2:Describe*",
"elasticache:Describe*",
"elasticbeanstalk:Check*",
"elasticbeanstalk:Describe*",
"elasticbeanstalk:List*",
"elasticbeanstalk:RequestEnvironmentInfo",
"elasticbeanstalk:RetrieveEnvironmentInfo",
"elasticloadbalancing:Describe*",
"elastictranscoder:Read*",
"elastictranscoder:List*",
"iam:List*",
"iam:Get*",
"kinesis:Describe*",
"kinesis:Get*",
"kinesis:List*",
"opsworks:Describe*",
"opsworks:Get*",
"route53:Get*",
"route53:List*",
"redshift:Describe*",
"redshift:ViewQueriesInConsole",
"rds:Describe*",
"rds:ListTagsForResource",
"s3:Get*",
"s3:List*",
"sdb:GetAttributes",
"sdb:List*",
"sdb:Select*",
"ses:Get*",
"ses:List*",
"sns:Get*",
"sns:List*",
"sqs:GetQueueAttributes",
"sqs:ListQueues",
"sqs:ReceiveMessage",
"storagegateway:List*",
"storagegateway:Describe*",
"trustedadvisor:Describe*"
],
"Effect": "Allow",
"Resource": ""
},
{
"Action": "aws-portal:Billing",
"Effect": "Deny",
"Resource": ""
},
{
"Action": [
"account:GetAccountInformation",
"billing:GetBillingData",
"billing:GetBillingDetails",
"billing:GetBillingNotifications",
"billing:GetBillingPreferences",
"billing:GetContractInformation",
"billing:GetCredits",
"billing:GetIAMAccessPreference",
"billing:GetSellerOfRecord",
"billing:ListBillingViews",
"billing:PutContractInformation",
"billing:RedeemCredits",
"billing:UpdateBillingPreferences",
"ce:CreateAnomalyMonitor",
"ce:CreateAnomalySubscription",
"ce:CreateNotificationSubscription",
"ce:CreateReport",
"ce:DeleteAnomalyMonitor",
"ce:DeleteAnomalySubscription",
"ce:DeleteNotificationSubscription",
"ce:DeleteReport",
"ce:DescribeNotificationSubscription",
"ce:DescribeReport",
"ce:GetAnomalies",
"ce:GetAnomalyMonitors",
"ce:GetAnomalySubscriptions",
"ce:GetCostAndUsage",
"ce:GetCostAndUsageWithResources",
"ce:GetCostCategories",
"ce:GetCostForecast",
"ce:GetDimensionValues",
"ce:GetPreferences",
"ce:GetReservationCoverage",
"ce:GetReservationPurchaseRecommendation",
"ce:GetReservationUtilization",
"ce:GetRightsizingRecommendation",
"ce:GetSavingsPlansCoverage",
"ce:GetSavingsPlansPurchaseRecommendation",
"ce:GetSavingsPlansUtilization",
"ce:GetSavingsPlansUtilizationDetails",
"ce:GetTags",
"ce:GetUsageForecast",
"ce:ListCostAllocationTags",
"ce:ListSavingsPlansPurchaseRecommendationGeneration",
"ce:ProvideAnomalyFeedback",
"ce:StartSavingsPlansPurchaseRecommendationGeneration",
"ce:UpdateAnomalyMonitor",
"ce:UpdateAnomalySubscription",
"ce:UpdateCostAllocationTagsStatus",
"ce:UpdateNotificationSubscription",
"ce:UpdatePreferences",
"consolidatedbilling:GetAccountBillingRole",
"consolidatedbilling:ListLinkedAccounts",
"cur:GetClassicReport",
"cur:GetClassicReportPreferences",
"cur:PutClassicReportPreferences",
"cur:ValidateReportDestination",
"freetier:GetFreeTierAlertPreference",
"freetier:GetFreeTierUsage",
"freetier:PutFreeTierAlertPreference",
"invoicing:GetInvoiceEmailDeliveryPreferences",
"invoicing:GetInvoicePDF",
"invoicing:ListInvoiceSummaries",
"invoicing:PutInvoiceEmailDeliveryPreferences",
"payments:CreatePaymentInstrument",
"payments:DeletePaymentInstrument",
"payments:GetPaymentInstrument",
"payments:GetPaymentStatus",
"payments:ListPaymentPreferences",
"payments:MakePayment",
"payments:UpdatePaymentPreferences",
"tax:BatchPutTaxRegistration",
"tax:DeleteTaxRegistration",
"tax:GetTaxInheritance",
"tax:GetTaxRegistrationDocument",
"tax:ListTaxRegistrations",
"tax:PutTaxInheritance"
],
"Effect": "Deny",
"Resource": ""
}
],
"Version": "2012-10-17"
}
IamSysAdminPolicy
{
"Statement": [
{
"NotAction": "iam:",
"Condition": {
"Bool": {
"aws:MultiFactorAuthPresent": "true"
}
},
"Effect": "Allow",
"Resource": ""
},
{
"Action": "aws-portal:Billing",
"Effect": "Deny",
"Resource": ""
},
{
"Action": [
"account:GetAccountInformation",
"billing:GetBillingData",
"billing:GetBillingDetails",
"billing:GetBillingNotifications",
"billing:GetBillingPreferences",
"billing:GetContractInformation",
"billing:GetCredits",
"billing:GetIAMAccessPreference",
"billing:GetSellerOfRecord",
"billing:ListBillingViews",
"billing:PutContractInformation",
"billing:RedeemCredits",
"billing:UpdateBillingPreferences",
"ce:CreateAnomalyMonitor",
"ce:CreateAnomalySubscription",
"ce:CreateNotificationSubscription",
"ce:CreateReport",
"ce:DeleteAnomalyMonitor",
"ce:DeleteAnomalySubscription",
"ce:DeleteNotificationSubscription",
"ce:DeleteReport",
"ce:DescribeNotificationSubscription",
"ce:DescribeReport",
"ce:GetAnomalies",
"ce:GetAnomalyMonitors",
"ce:GetAnomalySubscriptions",
"ce:GetCostAndUsage",
"ce:GetCostAndUsageWithResources",
"ce:GetCostCategories",
"ce:GetCostForecast",
"ce:GetDimensionValues",
"ce:GetPreferences",
"ce:GetReservationCoverage",
"ce:GetReservationPurchaseRecommendation",
"ce:GetReservationUtilization",
"ce:GetRightsizingRecommendation",
"ce:GetSavingsPlansCoverage",
"ce:GetSavingsPlansPurchaseRecommendation",
"ce:GetSavingsPlansUtilization",
"ce:GetSavingsPlansUtilizationDetails",
"ce:GetTags",
"ce:GetUsageForecast",
"ce:ListCostAllocationTags",
"ce:ListSavingsPlansPurchaseRecommendationGeneration",
"ce:ProvideAnomalyFeedback",
"ce:StartSavingsPlansPurchaseRecommendationGeneration",
"ce:UpdateAnomalyMonitor",
"ce:UpdateAnomalySubscription",
"ce:UpdateCostAllocationTagsStatus",
"ce:UpdateNotificationSubscription",
"ce:UpdatePreferences",
"consolidatedbilling:GetAccountBillingRole",
"consolidatedbilling:ListLinkedAccounts",
"cur:GetClassicReport",
"cur:GetClassicReportPreferences",
"cur:PutClassicReportPreferences",
"cur:ValidateReportDestination",
"freetier:GetFreeTierAlertPreference",
"freetier:GetFreeTierUsage",
"freetier:PutFreeTierAlertPreference",
"invoicing:GetInvoiceEmailDeliveryPreferences",
"invoicing:GetInvoicePDF",
"invoicing:ListInvoiceSummaries",
"invoicing:PutInvoiceEmailDeliveryPreferences",
"payments:CreatePaymentInstrument",
"payments:DeletePaymentInstrument",
"payments:GetPaymentInstrument",
"payments:GetPaymentStatus",
"payments:ListPaymentPreferences",
"payments:MakePayment",
"payments:UpdatePaymentPreferences",
"tax:BatchPutTaxRegistration",
"tax:DeleteTaxRegistration",
"tax:GetTaxInheritance",
"tax:GetTaxRegistrationDocument",
"tax:ListTaxRegistrations",
"tax:PutTaxInheritance"
],
"Effect": "Deny",
"Resource": ""
},
{
"Action": [
"cloudtrail:DeleteTrail",
"cloudtrail:StopLogging",
"cloudtrail:UpdateTrail"
],
"Effect": "Deny",
"Resource": ""
},
{
"Action": [
"kms:Create*",
"kms:Revoke*",
"kms:Enable*",
"kms:Get*",
"kms:Disable*",
"kms:Delete*",
"kms:Put*",
"kms:Update*"
],
"Effect": "Deny",
"Resource": "*"
}
],
"Version": "2012-10-17"
}
Logging
CloudTrail
証跡名 | マルチリージョンの証跡 | 証跡ログの場所 | 暗号化 | ログファイルの検証 | CloudWatch Logs | IAMロール | 備考 |
---|---|---|---|---|---|---|---|
LoggingCloudTrail | はい | loggingcloudtrailbucket | LoggingCloudTrailKey | 有効 |
Config
配信先バケット | IAMロール | 記録するリソース | グローバルリソースの記録 | データ保持期間 | 備考 |
---|---|---|---|---|---|
loggingconfigbucket | LoggingConfigRole | 全て | 有効 | 7年 |
S3
loggingcloudtrailbucket
項目 | 設定値 | 備考 |
---|---|---|
バケット名 | loggingcloudtrailbucket | |
AWSリージョン | ap-northeast-1 | |
オブジェクト所有者 | ACL無効 | AWS推奨値 |
バージョニング | 有効 | バージョニング有効にすることで格納したファイルが消されずにバージョン管理されていく動きになる。意図しない変更・削除からオブジェクトを復元を可能にする |
サーバーアクセスのログ記録 | 有効(loggingcloudtrailaccesslogbucket) | S3へのアクセスのログ。デバッグ用途で使用したい場合は有効にする |
オブジェクトレベルのログ記録 | 無効 | CloudTrailにS3上オブジェクトに対するgetやputなどのログも記録したい場合は有効とする(CloudTrail側で設定) |
デフォルトの暗号化(暗号化タイプ) | SSE-S3 | デフォルト値。特にデータ保護要件がなければデフォルトとする |
デフォルトの暗号化(バケットキー) | 無効 | デフォルト値 |
オブジェクトのロック | 無効 | デフォルト値。前提としてバージョニング有効にする必要あり。一定期間オブジェクトの削除を禁止する |
パブリックアクセスブロック
パブリックアクセスをすべて ブロック
項目 | 設定値 | 備考 |
---|---|---|
新しいACLを介して付与されたバケットとオブジェクトへのパブリックアクセスをブロックする | 有効 | |
任意のACLを介して付与されたバケットとオブジェクトへのパブリックアクセスをブロックする | 有効 | |
新しいパブリックバケットポリシーまたはアクセスポイントポリシーを介して付与されたバケットとオブジェクトへのパブリックアクセスをブロックする | 有効 | |
任意のパブリックバケットポリシーまたはアクセスポイントポリシーを介したバケットとオブジェクトへのパブリックアクセスとクロスアカウントアクセスをブロックする | 有効 |
バケットポリシー
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::dev-bleagovbasestandalone-loggingcloudtrailbucketx-xxxxxxxxxxxx",
"arn:aws:s3:::dev-bleagovbasestandalone-loggingcloudtrailbucketx-xxxxxxxxxxxx/*"
],
"Condition": {
"Bool": {
"aws:SecureTransport": "false"
}
}
},
{
"Sid": "Restrict Delete* Actions",
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "s3:Delete*",
"Resource": "arn:aws:s3:::dev-bleagovbasestandalone-loggingcloudtrailbucketx-xxxxxxxxxxxx/*"
},
{
"Effect": "Allow",
"Principal": {
"Service": "cloudtrail.amazonaws.com"
},
"Action": "s3:GetBucketAcl",
"Resource": "arn:aws:s3:::dev-bleagovbasestandalone-loggingcloudtrailbucketx-xxxxxxxxxxxx"
},
{
"Effect": "Allow",
"Principal": {
"Service": "cloudtrail.amazonaws.com"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::dev-bleagovbasestandalone-loggingcloudtrailbucketx-xxxxxxxxxxxx/AWSLogs/xxxxxxxxxxxx/*",
"Condition": {
"StringEquals": {
"s3:x-amz-acl": "bucket-owner-full-control"
}
}
}
]
}
ライフサイクルルール
設定なし
loggingcloudtrailaccesslogbucket
項目 | 設定値 | 備考 |
---|---|---|
バケット名 | loggingcloudtrailaccesslogbucket | |
AWSリージョン | ap-northeast-1 | |
オブジェクト所有者 | ACL無効 | AWS推奨値 |
バージョニング | 有効 | バージョニング有効にすることで格納したファイルが消されずにバージョン管理されていく動きになる。意図しない変更・削除からオブジェクトを復元を可能にする |
サーバーアクセスのログ記録 | 無効 | S3へのアクセスのログ。デバッグ用途で使用したい場合は有効にする |
オブジェクトレベルのログ記録 | 無効 | CloudTrailにS3上オブジェクトに対するgetやputなどのログも記録したい場合は有効とする(CloudTrail側で設定) |
デフォルトの暗号化(暗号化タイプ) | SSE-S3 | デフォルト値。特にデータ保護要件がなければデフォルトとする |
デフォルトの暗号化(バケットキー) | 無効 | デフォルト値 |
オブジェクトのロック | 無効 | デフォルト値。前提としてバージョニング有効にする必要あり。一定期間オブジェクトの削除を禁止する |
パブリックアクセスブロック
パブリックアクセスをすべて ブロック
項目 | 設定値 | 備考 |
---|---|---|
新しいACLを介して付与されたバケットとオブジェクトへのパブリックアクセスをブロックする | 有効 | |
任意のACLを介して付与されたバケットとオブジェクトへのパブリックアクセスをブロックする | 有効 | |
新しいパブリックバケットポリシーまたはアクセスポイントポリシーを介して付与されたバケットとオブジェクトへのパブリックアクセスをブロックする | 有効 | |
任意のパブリックバケットポリシーまたはアクセスポイントポリシーを介したバケットとオブジェクトへのパブリックアクセスとクロスアカウントアクセスをブロックする | 有効 |
バケットポリシー
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::dev-bleagovbasestandalone-loggingcloudtrailaccessl-xxxxxxxxxxxx",
"arn:aws:s3:::dev-bleagovbasestandalone-loggingcloudtrailaccessl-xxxxxxxxxxxx/*"
],
"Condition": {
"Bool": {
"aws:SecureTransport": "false"
}
}
},
{
"Sid": "Restrict Delete* Actions",
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "s3:Delete*",
"Resource": "arn:aws:s3:::dev-bleagovbasestandalone-loggingcloudtrailaccessl-xxxxxxxxxxxx/*"
},
{
"Effect": "Allow",
"Principal": {
"Service": "logging.s3.amazonaws.com"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::dev-bleagovbasestandalone-loggingcloudtrailaccessl-xxxxxxxxxxxx/cloudtraillogs*",
"Condition": {
"StringEquals": {
"aws:SourceAccount": "xxxxxxxxxxxx"
},
"ArnLike": {
"aws:SourceArn": "arn:aws:s3:::dev-bleagovbasestandalone-loggingcloudtrailbucketx-xxxxxxxxxxxx"
}
}
}
]
}
ライフサイクルルール
ライフサイクルルール名 | ルールスコープ |
---|---|
<ランダムな文字列> | このルールは、バケット内のすべてのオブジェクトに適用されます |
ライフサイクルルールアクション:Delete-After-396Days
項目名 | 設定値 | 備考 |
---|---|---|
ライフサイクルルールのアクション | 現行バージョンのオブジェクトをストレージクラス間で移行する オブジェクトの現行バージョンを有効期限切れにする |
7年後に期限切れ |
現行バージョンのオブジェクトをストレージクラス間で移行する | 90日後にGlacier Flexible Retrievalに移行 | オブジェクト作成後、指定日数経過後にストレージクラスを移動する |
オブジェクトの現行バージョンを有効期限切れにする | 2555日(7年) | オブジェクト作成後、指定日数経過後に非現行バージョンにする |
loggingconfigbucket
項目 | 設定値 | 備考 |
---|---|---|
バケット名 | loggingconfigbucket | |
AWSリージョン | ap-northeast-1 | |
オブジェクト所有者 | ACL無効 | AWS推奨値 |
バージョニング | 有効 | バージョニング有効にすることで格納したファイルが消されずにバージョン管理されていく動きになる。意図しない変更・削除からオブジェクトを復元を可能にする |
サーバーアクセスのログ記録 | 無効 | S3へのアクセスのログ。デバッグ用途で使用したい場合は有効にする |
オブジェクトレベルのログ記録 | 無効 | CloudTrailにS3上オブジェクトに対するgetやputなどのログも記録したい場合は有効とする(CloudTrail側で設定) |
デフォルトの暗号化(暗号化タイプ) | SSE-S3 | デフォルト値。特にデータ保護要件がなければデフォルトとする |
デフォルトの暗号化(バケットキー) | 無効 | デフォルト値 |
オブジェクトのロック | 無効 | デフォルト値。前提としてバージョニング有効にする必要あり。一定期間オブジェクトの削除を禁止する |
パブリックアクセスブロック
パブリックアクセスをすべて ブロック
項目 | 設定値 | 備考 |
---|---|---|
新しいACLを介して付与されたバケットとオブジェクトへのパブリックアクセスをブロックする | 有効 | |
任意のACLを介して付与されたバケットとオブジェクトへのパブリックアクセスをブロックする | 有効 | |
新しいパブリックバケットポリシーまたはアクセスポイントポリシーを介して付与されたバケットとオブジェクトへのパブリックアクセスをブロックする | 有効 | |
任意のパブリックバケットポリシーまたはアクセスポイントポリシーを介したバケットとオブジェクトへのパブリックアクセスとクロスアカウントアクセスをブロックする | 有効 |
バケットポリシー
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::dev-bleagovbasestandalone-loggingconfigbucketxxxxx-xxxxxxxxxxxx",
"arn:aws:s3:::dev-bleagovbasestandalone-loggingconfigbucketxxxxx-xxxxxxxxxxxx/*"
],
"Condition": {
"Bool": {
"aws:SecureTransport": "false"
}
}
},
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::xxxxxxxxxxxx:role/Dev-BLEAGovBaseStandalone-LoggingConfigRolexxxxxxxx-xxxxxxxxxxxx"
},
"Action": "s3:GetBucketAcl",
"Resource": "arn:aws:s3:::dev-bleagovbasestandalone-loggingconfigbucketxxxxx-xxxxxxxxxxxx"
},
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::xxxxxxxxxxxx:role/Dev-BLEAGovBaseStandalone-LoggingConfigRolexxxxxxxx-xxxxxxxxxxxx"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::dev-bleagovbasestandalone-loggingconfigbucketxxxxx-xxxxxxxxxxxx/AWSLogs/xxxxxxxxxxxx/Config/*",
"Condition": {
"StringEquals": {
"s3:x-amz-acl": "bucket-owner-full-control"
}
}
}
]
}
ライフサイクルルール
特になし
CloudWatch
ロググループ
ロググループ名 | 保持期間 | 備考 |
---|---|---|
LoggingCloudTrailLogGroup | 90 |
KMS
キーポリシー | ローテーション期間 | 備考 |
---|---|---|
下記記載 | 365日 | CloudTrailのログ暗号化用キー |
{
"Statement": [
{
"Action": "kms:",
"Effect": "Allow",
"Principal": {
"AWS": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":iam::xxxxxxxxxxxx:root"
]
]
}
},
"Resource": ""
},
{
"Action": "kms:GenerateDataKey*",
"Condition": {
"StringLike": {
"kms:EncryptionContext:aws:cloudtrail:arn": [
"arn:aws:cloudtrail::xxxxxxxxxxxx:trail/"
]
}
},
"Effect": "Allow",
"Principal": {
"Service": "cloudtrail.amazonaws.com"
},
"Resource": ""
},
{
"Action": "kms:DescribeKey",
"Effect": "Allow",
"Principal": {
"Service": "cloudtrail.amazonaws.com"
},
"Resource": ""
},
{
"Action": [
"kms:Decrypt",
"kms:ReEncryptFrom"
],
"Condition": {
"StringEquals": {
"kms:CallerAccount": "xxxxxxxxxxxx"
},
"StringLike": {
"kms:EncryptionContext:aws:cloudtrail:arn": [
"arn:aws:cloudtrail::xxxxxxxxxxxx:trail/"
]
}
},
"Effect": "Allow",
"Principal": {
"AWS": ""
},
"Resource": ""
},
{
"Action": [
"kms:Encrypt*",
"kms:Decrypt*",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:Describe*"
],
"Condition": {
"ArnEquals": {
"kms:EncryptionContext:aws:logs:arn": "arn:aws:logs:ap-northeast-1:xxxxxxxxxxxx:log-group:"
}
},
"Effect": "Allow",
"Principal": {
"Service": "logs.amazonaws.com"
},
"Resource": ""
}
],
"Version": "2012-10-17"
}
IAM
IAMロール
ロール名 | 信頼されたエンティティ | ポリシー | 備考 |
---|---|---|---|
LoggingCloudTrailLogsRole | cloudtrail | LoggingCloudTrailLogsRoleDefaultPolicy | |
LoggingConfigRole | config | AWS_ConfigRole |
IAMポリシー
LoggingCloudTrailLogsRoleDefaultPolicy
{
"Statement": [
{
"Action": [
"logs:PutLogEvents",
"logs:CreateLogStream"
],
"Effect": "Allow",
"Resource": {
"Fn::GetAtt": [
"LoggingCloudTrailLogGroupxxxxxxxx",
"Arn"
]
}
}
],
"Version": "2012-10-17"
}
Notification
Chatbot
チャネル
項目 | 設定値 | 備考 |
---|---|---|
チャネル名 | DevBLEAGovBaseStandaloneNotification | |
IAMロール | NotificationChatbotRole | |
送信先Slackチャネル | パラメータシートには記載しない | |
送信先Slackワークスペース | パラメータシートには記載しない | |
SNSトピック | DetectionAlarmTopic |
IAM
IAMロール
ロール名 | 信頼されたエンティティ | ポリシー | 備考 |
---|---|---|---|
NotificationChatbotRole | chatbot | CloudWatchReadOnlyAccess ReadOnlyAccess |
終わりに
デプロイされるリソースを整理することでBLEAの解像度もかなり高まりました。次回はControl Tower編!