回答

-1

您可以按照這裏的基本示例https://www.terraform.io/docs/providers/aws/r/security_group.html和這裏https://www.terraform.io/docs/providers/aws/r/emr_cluster.html

這將是類似於:

resource "aws_security_group" "sg" { 
    name = "allow_all" 
    description = "Allow all inbound traffic" 

    ingress { 
     from_port = 0 
     to_port = 0 
     protocol = "-1" 
     cidr_blocks = ["0.0.0.0/0"] 
    } 

    egress { 
     from_port = 0 
     to_port = 0 
     protocol = "-1" 
     cidr_blocks = ["0.0.0.0/0"] 
     prefix_list_ids = ["pl-12c4e678"] 
    } 
} 

resource "aws_emr_cluster" "emr-test-cluster" { 
    name   = "emr-test-arn" 
    release_label = "emr-4.6.0" 
    applications = ["Spark"] 

    termination_protection = false 
    keep_job_flow_alive_when_no_steps = true 

    ec2_attributes { 
    subnet_id       = "${aws_subnet.main.id}" 
    emr_managed_master_security_group = "${aws_security_group.sg.id}" 
    emr_managed_slave_security_group = "${aws_security_group.sg.id}" 
    instance_profile     = "${aws_iam_instance_profile.emr_profile.arn}" 
    } 
... 
} 
+1

問題與安全組無關。 –

0

更新2017年6月7日:作爲Jun 6 2017,該AWS::EMR::SecurityConfiguration資源現在在CloudFormation可用,並且爲2017年5月11日(v0.9.5)的Terraform中提供了emr_security_configuration資源。


不幸的是,它看起來並不像它目前可以指定使用任何CloudFormation的AWS::EMR::Cluster CloudFormation資源或Terraform的aws_emr_cluster資源RunJobFlow API一個SecurityConfiguration,並且有對應CreateSecurityConfiguration API沒有資源。

Sep 21 2016上新增了EMR Security Configuration功能,新功能通告與其在現有CloudFormation資源中的相應支持之間通常存在滯後。

雖然Terraform的更新速度更快,因爲它是一個開源社區的開源項目,但aws_emr_cluster資源仍然比較新(發佈Oct 6 2016)。我打開了一個GitHub issue跟蹤此實現的功能請求。

作爲現在的解決方法,您可以創建一個Custom Resource,它直接調用CreateSecurityConfigurationRunJobFlow API。

相關問題