Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS Storage Gateway SMB security settings #9382

Closed
ghost opened this issue Jul 17, 2019 · 5 comments · Fixed by #13563
Closed

AWS Storage Gateway SMB security settings #9382

ghost opened this issue Jul 17, 2019 · 5 comments · Fixed by #13563
Assignees
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/storagegateway Issues and PRs that pertain to the storagegateway service.
Milestone

Comments

@ghost
Copy link

ghost commented Jul 17, 2019

This issue was originally opened by @thorvats as hashicorp/terraform#22084. It was migrated here as a result of the provider split. The original body of the issue is below.


Current Terraform Version

Terraform v0.11.10

Use-cases

Create terraform Storage Gateway resources for storage_gw account

resource "aws_s3_bucket" "storage_gw" {
  bucket        = "${var.target_infra}-storage_gw-share"
  acl           = "private"

  server_side_encryption_configuration {
    rule {
      apply_server_side_encryption_by_default {
        kms_master_key_id = "${aws_kms_key.data.arn}"
        sse_algorithm     = "aws:kms"
      }
    }
  }
  lifecycle_rule {
    id          = "storage_gw"
    enabled     = true
    transition {
      days          = 30
      storage_class = "ONEZONE_IA"
    }

    transition {
      days          = 90
      storage_class = "GLACIER"
    }

    expiration {
      days          = 180
    }
  }
  tags = "${merge(
    local.common_tags,
    map(
      "Name", "${var.target_infra}-storage_gw-share"
    )
  )}"
}

data "template_file" "s3-storage_gw" {
  template = "${file("${path.module}/templates/stg-gw-bucket-policy.json")}"

  vars {
    account_id       = "${data.aws_caller_identity.this.account_id}"
    bucket_name      = "${aws_s3_bucket.storage_gw.id}"
    app_account_id   = "${accountId}"
    data_kms_arn     = "${aws_kms_key.data.arn}"
    assumed_role_id  = "${element(split(":",data.aws_caller_identity.this.user_id),0)}"
  }
}

resource "aws_s3_bucket_policy" "storage_gw" {
  bucket   = "${aws_s3_bucket.storage_gw.id}"
  policy   = "${data.template_file.s3-storage_gw.rendered}"
}

data "template_file" "sgw-storage_gw" {
  template = "${file("${path.module}/templates/stg-gw-policy.json")}"

  vars {
    bucket_name  = "${aws_s3_bucket.storage_gw.id}"
    data_kms_arn = "${aws_kms_key.data.arn}"
  }
}

resource "aws_iam_role" "storage_gw" {
  name_prefix        = "${var.target_infra}-storage_gw-stg-gw-"
  description        = "Allow storage gateway to write to s3"
  assume_role_policy = "${file("${path.module}/templates/assume-stg-gw.json")}"

  tags = "${merge(
    local.common_tags,
    map(
      "Name", "${var.target_infra}-storage_gw-storage-gateway-role"
    )
  )}"
}

resource "aws_iam_role_policy" "storage_gw" {
  name_prefix = "${var.target_infra}-storage_gw-stg-gw-policy-"
  role        = "${aws_iam_role.storage_gw.id}"
  policy      = "${data.template_file.sgw-storage_gw.rendered}"
}

resource "aws_storagegateway_smb_file_share" "storage_gw" {
  authentication  = "ActiveDirectory"
  gateway_arn     = "${aws_storagegateway_gateway.storage_gateway.arn}"
  location_arn    = "${aws_s3_bucket.storage_gw.arn}"
  role_arn        = "${aws_iam_role.storage_gw.arn}"
  kms_encrypted   = true
  kms_key_arn     = "${aws_kms_key.data.arn}"
  valid_user_list = ["@AWS-${var.target_infra}-storage-gw-share"]
  depends_on      = ["aws_iam_role_policy.storage_gw"]

}

resource "aws_storagegateway_gateway" "storage_gateway" {
  activation_key     = "${local.sgw_activation_key[var.target_infra]}"
  gateway_name       = "${var.target_infra}-${local.app_name}-storagagateway"
  gateway_timezone   = "GMT"
  gateway_type       = "FILE_S3"
  
  smb_active_directory_settings {
    domain_name        = "domain.local"
    username           = "${local.sgw_domain_username}"
    password           = "${var.sgw_domain_password}"
  }
}

data "aws_storagegateway_local_disk" "sgw_disk" {
  disk_path   = "/dev/sdb"
  gateway_arn = "${aws_storagegateway_gateway.storage_gateway.arn}"
}

resource "aws_storagegateway_cache" "sgw_cache" {
  disk_id     = "${data.aws_storagegateway_local_disk.sgw_disk.id}"
  gateway_arn = "${aws_storagegateway_gateway.storage_gateway.arn}"
}

Attempted Solutions

These settings were manually updated on console after deploying AWS Storage Gateway : File Gateway as per AWS article mentioned below.

https://docs.aws.amazon.com/storagegateway/latest/userguide/managing-gateway-file.html#security-strategy

Proposal

Add property smb_sec_settings in AWS Storage Gateway resource like in terrafom module - https://www.terraform.io/docs/providers/aws/r/storagegateway_gateway.html

with vaules like,

values: " ", "encrypted" , "signed" , "negotiated"

References

https://docs.aws.amazon.com/storagegateway/latest/userguide/managing-gateway-file.html#security-strategy
https://www.terraform.io/docs/providers/aws/r/storagegateway_gateway.html
Storage Gateway Manual Settings.docx

@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jul 17, 2019
@aeschright aeschright added the service/s3 Issues and PRs that pertain to the s3 service. label Aug 2, 2019
@pintbrewer
Copy link

This became an issue for me once AWS change the default setting for new Gateways.

excerpt from: https://docs.aws.amazon.com/storagegateway/latest/userguide/managing-gateway-file.html#security-strategy

Note
For gateways activated before June 20, 2019, the default security level is Client negotiated.
For gateways activated on June 20, 2019 and later, the default security level is Enforce encryption.

I agree with the proposal above.

@DrFaust92 DrFaust92 added the service/storagegateway Issues and PRs that pertain to the storagegateway service. label May 21, 2020
@DrFaust92 DrFaust92 removed the service/s3 Issues and PRs that pertain to the s3 service. label May 31, 2020
@DrFaust92
Copy link
Collaborator

addressed in #13563

@DrFaust92 DrFaust92 added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Aug 21, 2020
@bflad bflad added this to the v3.4.0 milestone Aug 21, 2020
@bflad bflad self-assigned this Aug 21, 2020
@bflad
Copy link
Contributor

bflad commented Aug 21, 2020

Support for the smb_security_strategy argument has been merged and will be released with version 3.4.0 of the Terraform AWS Provider, late next week. Thanks to @DrFaust92 for the implementation. 👍

@ghost
Copy link
Author

ghost commented Aug 27, 2020

This has been released in version 3.4.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link
Author

ghost commented Sep 20, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Sep 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/storagegateway Issues and PRs that pertain to the storagegateway service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants