diff --git a/modules/region/README.md b/modules/region/README.md index 846ecdf..c1f60f5 100644 --- a/modules/region/README.md +++ b/modules/region/README.md @@ -4,6 +4,7 @@ This module creates following resources. - `aws_ebs_encryption_by_default` - `aws_ebs_default_kms_key` (optional) +- `aws_ec2_image_block_public_access` - `aws_ec2_serial_console_access` - `aws_macie2_organization_admin_account` (optional) - `aws_resourceexplorer2_index` (optional) @@ -37,6 +38,7 @@ This module creates following resources. | [aws_ebs_default_kms_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ebs_default_kms_key) | resource | | [aws_ebs_encryption_by_default.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ebs_encryption_by_default) | resource | | [aws_ec2_availability_zone_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_availability_zone_group) | resource | +| [aws_ec2_image_block_public_access.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_image_block_public_access) | resource | | [aws_ec2_serial_console_access.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_serial_console_access) | resource | | [aws_macie2_organization_admin_account.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/macie2_organization_admin_account) | resource | | [aws_resourceexplorer2_index.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/resourceexplorer2_index) | resource | @@ -49,7 +51,7 @@ This module creates following resources. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [ebs\_default\_encryption](#input\_ebs\_default\_encryption) | (Optional) The configuration of the EBS default encryption. `ebs_default_encryption` as defined below.
(Optional) `enabled` - Whether or not default EBS encryption is enabled.
(Optional) `kms_key` - The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume. |
object({
enabled = optional(bool, false)
kms_key = optional(string)
})
| `{}` | no | -| [ec2\_serial\_console\_enabled](#input\_ec2\_serial\_console\_enabled) | (Optional) Whether serial console access is enabled for the current AWS region. | `bool` | `false` | no | +| [ec2](#input\_ec2) | (Optional) The configuration of EC2 in the current AWS region. `ec2` as defined below.
(Optional) `ami_public_access_enabled` - Whether to allow or block public access for AMIs at the account level to prevent the public sharing of your AMIs in this region. Defaults to `false`.
(Optional) `serial_console_enabled` - Whether serial console access is enabled for the current AWS region. Defaults to `false`. |
object({
ami_public_access_enabled = optional(bool, false)
serial_console_enabled = optional(bool, false)
})
| `{}` | no | | [macie](#input\_macie) | (Optional) The configuration of Macie in the current AWS region. `macie` as defined below.
(Optional) `delegated_administrator` - The AWS account ID for the account to designate as the delegated Amazon Macie administrator account for the organization. This can be configured only if Macie is enabled for the organization. The account must be a management account of the organization. |
object({
delegated_administrator = optional(string)
})
| `{}` | no | | [module\_tags\_enabled](#input\_module\_tags\_enabled) | (Optional) Whether to create AWS Resource Tags for the module informations. | `bool` | `true` | no | | [resource\_explorer](#input\_resource\_explorer) | (Optional) The configuration of the Resource Explorer in the current AWS region. `resource_explorer` as defined below.
(Optional) `enabled` - Whether or not to enable the Resource Explorer in the current AWS region. Defaults to `true`.
(Optional) `index_type` - The type of the index. Valid values are `AGGREGATOR`, `LOCAL`. Defaults to `LOCAL`.
(Optional) `views` - A list of views to create. `views` as defined below.
(Required) `name` - The name of the view. The name must be no more than 64 characters long, and can include letters, digits, and the dash (-) character. The name must be unique within its AWS Region.
(Optional) `is_default` - Whether the view is the default view for the AWS Region. Defaults to `false`.
(Optional) `filter_queries` - A list of filter queries. Specify which resources are included in the results of queries made using this view. The filter string is combined using a logical AND operator. Defaults to `[]` (include all resources).
(Optional) `additional_resource_attributes` - A list of additional resource attributes. By default, the results include ARN, owner account, Region, service, and resource type. Valid values are `tags`. Defaults to `[]`. |
object({
enabled = optional(bool, true)
index_type = optional(string, "LOCAL")
views = optional(list(object({
name = string
is_default = optional(bool, false)
filter_queries = optional(list(string), [])

additional_resource_attributes = optional(set(string), [])
})), [])
})
| `{}` | no | @@ -68,7 +70,7 @@ This module creates following resources. | [code](#output\_code) | The short code of the current region. | | [description](#output\_description) | The description of the current region in this format: `Location (Region name)` | | [ebs](#output\_ebs) | The region-level configurations of EBS service.
`default_encryption` - The configurations for EBS Default Encryption. | -| [ec2](#output\_ec2) | The region-level configurations of EC2 service.
`serial_console` - The configurations for EC2 Serial Console. | +| [ec2](#output\_ec2) | The region-level configurations of EC2 service.
`ami_public_access_enabled` - Whether to allow or block public access for AMIs at the account level to prevent the public sharing of your AMIs in this region.
`serial_console_enabled` - Whether serial console access is enabled for the current AWS region. | | [id](#output\_id) | The ID of the current region. | | [macie](#output\_macie) | The region-level configurations of Macie service.
`delegated_administrator` - The AWS account ID for the account to designate as the delegated Amazon Macie administrator account for the organization. | | [name](#output\_name) | The name of the current region. | diff --git a/modules/region/ec2.tf b/modules/region/ec2.tf index 12aae8f..85bcbbb 100644 --- a/modules/region/ec2.tf +++ b/modules/region/ec2.tf @@ -1,7 +1,19 @@ +################################################### +# Public Access Block for EC2 AMI +################################################### + +resource "aws_ec2_image_block_public_access" "this" { + state = (var.ec2.ami_public_access_enabled + ? "unblocked" + : "block-new-sharing" + ) +} + + ################################################### # Serial Consol Access for EC2 ################################################### resource "aws_ec2_serial_console_access" "this" { - enabled = var.ec2_serial_console_enabled + enabled = var.ec2.serial_console_enabled } diff --git a/modules/region/outputs.tf b/modules/region/outputs.tf index fc5a9bf..3b6cac5 100644 --- a/modules/region/outputs.tf +++ b/modules/region/outputs.tf @@ -34,12 +34,12 @@ output "ebs" { output "ec2" { description = <