generated from dxw/terraform-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from dxw/conditionally-create-transfer-s3-bucket
Conditionally create transfer S3 bucket
- Loading branch information
Showing
10 changed files
with
230 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
policies/kms-key-policy-statements/vpc-id-and-s3-bucket-allow.json.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
%{if vpc_ids != "[]"}{ | ||
"Effect": "Allow", | ||
"Principal": { | ||
"AWS": "*" | ||
}, | ||
"Action": [ | ||
"kms:Encrypt", | ||
"kms:Decrypt", | ||
"kms:ReEncrypt*", | ||
"kms:GenerateDataKey*" | ||
], | ||
"Resource": "*", | ||
"Condition": { | ||
"StringEquals": { | ||
"aws:sourceVpc": ${vpc_ids}, | ||
"kms:ViaService": "s3.${region}.amazonaws.com", | ||
"kms:EncryptionContext:SourceARN": "${bucket_arn}" | ||
} | ||
} | ||
}%{endif} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"Effect": "Allow", | ||
"Principal": "*", | ||
"Action": "s3:*", | ||
"Resource": "${bucket_arn}/*", | ||
"Condition": { | ||
"StringEquals": { | ||
"aws:sourceVpc": ${vpc_ids} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"schemaVersion": "1.0", | ||
"description": "Document to download from S3", | ||
"sessionType": "InteractiveCommands", | ||
"parameters": { | ||
"TargetUID": { | ||
"type": "String", | ||
"description": "The default unix UID of the target system", | ||
"default": "" | ||
}, | ||
"TargetGID": { | ||
"type": "String", | ||
"description": "The default unix GID of the target system", | ||
"default": "" | ||
}, | ||
"Source": { | ||
"type": "String", | ||
"description": "S3 Bucket source path" | ||
}, | ||
"HostTarget": { | ||
"type": "String", | ||
"description": "Target path on instance" | ||
}, | ||
"Recursive": { | ||
"type": "String", | ||
"description": "Recursive copy", | ||
"default": "--ignore-glacier-warnings", | ||
"allowedValues": [ | ||
"--ignore-glacier-warnings", | ||
"--recursive" | ||
] | ||
} | ||
}, | ||
"properties": { | ||
"linux": { | ||
"commands": "${command}", | ||
"runAsElevated": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"schemaVersion": "1.0", | ||
"description": "Document to uplaod to S3", | ||
"sessionType": "InteractiveCommands", | ||
"parameters": { | ||
"Source": { | ||
"type": "String", | ||
"description": "file source path" | ||
}, | ||
"S3Target": { | ||
"type": "String", | ||
"description": "s3 bucket path" | ||
}, | ||
"Recursive": { | ||
"type": "String", | ||
"description": "Recursive copy", | ||
"default": "--ignore-glacier-warnings", | ||
"allowedValues": [ | ||
"--ignore-glacier-warnings", | ||
"--recursive" | ||
] | ||
} | ||
}, | ||
"properties": { | ||
"linux": { | ||
"commands": "${command}", | ||
"runAsElevated": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
resource "aws_ssm_document" "infrastructure_vpc_transfer_s3_download" { | ||
count = local.enable_infrastructure_vpc_transfer_s3_bucket ? 1 : 0 | ||
|
||
name = "${local.resource_prefix_hash}-infrastructure-vpc-transfer-s3-download" | ||
document_type = "Session" | ||
content = templatefile("${path.root}/ssm-documents/s3-download.json.tpl", { | ||
command = local.infrastructure_vpc_transfer_ssm_download_command | ||
}) | ||
} | ||
|
||
resource "aws_ssm_document" "infrastructure_vpc_transfer_s3_upload" { | ||
count = local.enable_infrastructure_vpc_transfer_s3_bucket ? 1 : 0 | ||
|
||
name = "${local.resource_prefix_hash}-infrastructure-vpc-transfer-s3-upload" | ||
document_type = "Session" | ||
content = templatefile("${path.root}/ssm-documents/s3-upload.json.tpl", { | ||
command = local.infrastructure_vpc_transfer_ssm_upload_command | ||
}) | ||
} |
Oops, something went wrong.