Skip to content

Commit a95d8c8

Browse files
authored
fix: kms policy fixed (#55)
* fix: kms policy fixed * tflint error fixed
1 parent 7d9828a commit a95d8c8

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

_example/complete/example.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
## Provider block added, Use the Amazon Web Services (AWS) provider to interact with the many resources supported by AWS.
33
####----------------------------------------------------------------------------------
44
provider "aws" {
5-
region = "eu-west-1"
5+
region = "us-west-1"
66
}
77

88
locals {
@@ -31,7 +31,7 @@ module "public_subnets" {
3131
name = "public-subnet"
3232
environment = local.environment
3333
label_order = local.label_order
34-
availability_zones = ["eu-west-1b", "eu-west-1c"]
34+
availability_zones = ["us-west-1b", "us-west-1c"]
3535
vpc_id = module.vpc.vpc_id
3636
cidr_block = module.vpc.vpc_cidr_block
3737
type = "public"
@@ -91,7 +91,7 @@ module "ec2" {
9191
ssh_allowed_ports = [22]
9292
#Instance
9393
instance_count = 1
94-
ami = "ami-08d658f84a6d84a80"
94+
ami = "ami-0f8e81a3da6e2510a"
9595
instance_type = "t2.nano"
9696

9797
#Keypair

main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ resource "aws_kms_key" "default" {
120120
tags = module.labels.tags
121121
}
122122

123+
data "aws_caller_identity" "this" {}
124+
123125
resource "aws_kms_alias" "default" {
124126
count = var.enable && var.kms_key_enabled && var.kms_key_id == "" ? 1 : 0
125127
name = coalesce(var.alias, format("alias/%v", module.labels.id))
@@ -133,12 +135,11 @@ data "aws_iam_policy_document" "kms" {
133135
effect = "Allow"
134136
principals {
135137
type = "AWS"
136-
identifiers = ["*"]
138+
identifiers = [format("arn:aws:iam::%s:root", data.aws_caller_identity.this.account_id)]
137139
}
138140
actions = ["kms:*"]
139141
resources = ["*"]
140142
}
141-
142143
}
143144

144145
##----------------------------------------------------------------------------------

variables.tf

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ variable "cpu_core_count" {
234234

235235
variable "iam_instance_profile" {
236236
type = string
237-
default = ""
237+
default = null
238238
description = "The IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile."
239239
}
240240

@@ -495,12 +495,6 @@ variable "public_key" {
495495
sensitive = true
496496
}
497497

498-
variable "key_path" {
499-
type = string
500-
default = ""
501-
description = "Name (e.g. `~/.ssh/id_rsa.pub`)."
502-
}
503-
504498
###### spot
505499
variable "spot_instance_enabled" {
506500
type = bool

0 commit comments

Comments
 (0)