Use aws_s3_object instead of deprecated aws_s3_bucket_object

This commit is contained in:
Ciprian Hacman 2022-04-13 07:15:50 +03:00
parent 3a5de4315b
commit 8b8dd8d2dd
7 changed files with 62 additions and 62 deletions

View File

@ -143,7 +143,7 @@ func (i *integrationTest) withDedicatedAPIServer() *integrationTest {
"aws_iam_role_apiservers."+i.clusterName+"_policy",
"aws_iam_role_policy_apiservers."+i.clusterName+"_policy",
"aws_launch_template_apiserver.apiservers."+i.clusterName+"_user_data",
"aws_s3_bucket_object_nodeupconfig-apiserver_content",
"aws_s3_object_nodeupconfig-apiserver_content",
)
return i
}
@ -166,7 +166,7 @@ func (i *integrationTest) withOIDCDiscovery() *integrationTest {
func (i *integrationTest) withManagedFiles(files ...string) *integrationTest {
for _, file := range files {
i.expectTerraformFilenames = append(i.expectTerraformFilenames,
"aws_s3_bucket_object_"+file+"_content")
"aws_s3_object_"+file+"_content")
}
return i
}
@ -174,7 +174,7 @@ func (i *integrationTest) withManagedFiles(files ...string) *integrationTest {
func (i *integrationTest) withAddons(addons ...string) *integrationTest {
for _, addon := range addons {
i.expectTerraformFilenames = append(i.expectTerraformFilenames,
"aws_s3_bucket_object_"+i.clusterName+"-addons-"+addon+"_content")
"aws_s3_object_"+i.clusterName+"-addons-"+addon+"_content")
}
return i
}
@ -643,8 +643,8 @@ func TestKarpenter(t *testing.T) {
test.expectTerraformFilenames = append(test.expectTerraformFilenames,
"aws_launch_template_karpenter-nodes-single-machinetype.minimal.example.com_user_data",
"aws_launch_template_karpenter-nodes-default.minimal.example.com_user_data",
"aws_s3_bucket_object_nodeupconfig-karpenter-nodes-single-machinetype_content",
"aws_s3_bucket_object_nodeupconfig-karpenter-nodes-default_content",
"aws_s3_object_nodeupconfig-karpenter-nodes-single-machinetype_content",
"aws_s3_object_nodeupconfig-karpenter-nodes-default_content",
)
test.runTestTerraformAWS(t)
}
@ -1119,31 +1119,31 @@ func (i *integrationTest) runTestTerraformAWS(t *testing.T) {
expectedFilenames := i.expectTerraformFilenames
expectedFilenames = append(expectedFilenames,
"aws_launch_template_nodes."+i.clusterName+"_user_data",
"aws_s3_bucket_object_cluster-completed.spec_content",
"aws_s3_bucket_object_etcd-cluster-spec-events_content",
"aws_s3_bucket_object_etcd-cluster-spec-main_content",
"aws_s3_bucket_object_kops-version.txt_content",
"aws_s3_bucket_object_manifests-etcdmanager-events_content",
"aws_s3_bucket_object_manifests-etcdmanager-main_content",
"aws_s3_bucket_object_manifests-static-kube-apiserver-healthcheck_content",
"aws_s3_bucket_object_nodeupconfig-nodes_content",
"aws_s3_bucket_object_"+i.clusterName+"-addons-bootstrap_content",
"aws_s3_bucket_object_"+i.clusterName+"-addons-core.addons.k8s.io_content",
"aws_s3_bucket_object_"+i.clusterName+"-addons-kops-controller.addons.k8s.io-k8s-1.16_content",
"aws_s3_bucket_object_"+i.clusterName+"-addons-kubelet-api.rbac.addons.k8s.io-k8s-1.9_content",
"aws_s3_bucket_object_"+i.clusterName+"-addons-limit-range.addons.k8s.io_content",
"aws_s3_bucket_object_"+i.clusterName+"-addons-storage-aws.addons.k8s.io-v1.15.0_content")
"aws_s3_object_cluster-completed.spec_content",
"aws_s3_object_etcd-cluster-spec-events_content",
"aws_s3_object_etcd-cluster-spec-main_content",
"aws_s3_object_kops-version.txt_content",
"aws_s3_object_manifests-etcdmanager-events_content",
"aws_s3_object_manifests-etcdmanager-main_content",
"aws_s3_object_manifests-static-kube-apiserver-healthcheck_content",
"aws_s3_object_nodeupconfig-nodes_content",
"aws_s3_object_"+i.clusterName+"-addons-bootstrap_content",
"aws_s3_object_"+i.clusterName+"-addons-core.addons.k8s.io_content",
"aws_s3_object_"+i.clusterName+"-addons-kops-controller.addons.k8s.io-k8s-1.16_content",
"aws_s3_object_"+i.clusterName+"-addons-kubelet-api.rbac.addons.k8s.io-k8s-1.9_content",
"aws_s3_object_"+i.clusterName+"-addons-limit-range.addons.k8s.io_content",
"aws_s3_object_"+i.clusterName+"-addons-storage-aws.addons.k8s.io-v1.15.0_content")
if i.kubeDNS {
expectedFilenames = append(expectedFilenames, "aws_s3_bucket_object_"+i.clusterName+"-addons-kube-dns.addons.k8s.io-k8s-1.12_content")
expectedFilenames = append(expectedFilenames, "aws_s3_object_"+i.clusterName+"-addons-kube-dns.addons.k8s.io-k8s-1.12_content")
} else {
expectedFilenames = append(expectedFilenames, "aws_s3_bucket_object_"+i.clusterName+"-addons-coredns.addons.k8s.io-k8s-1.12_content")
expectedFilenames = append(expectedFilenames, "aws_s3_object_"+i.clusterName+"-addons-coredns.addons.k8s.io-k8s-1.12_content")
}
if i.discovery {
expectedFilenames = append(expectedFilenames,
"aws_s3_bucket_object_discovery.json_content",
"aws_s3_bucket_object_keys.json_content")
"aws_s3_object_discovery.json_content",
"aws_s3_object_keys.json_content")
}
if i.sshKey {
@ -1156,7 +1156,7 @@ func (i *integrationTest) runTestTerraformAWS(t *testing.T) {
for j := 0; j < i.zones; j++ {
zone := "us-test-1" + string([]byte{byte('a') + byte(j)})
expectedFilenames = append(expectedFilenames,
"aws_s3_bucket_object_nodeupconfig-master-"+zone+"_content",
"aws_s3_object_nodeupconfig-master-"+zone+"_content",
"aws_launch_template_master-"+zone+".masters."+i.clusterName+"_user_data")
}
@ -1174,13 +1174,13 @@ func (i *integrationTest) runTestTerraformAWS(t *testing.T) {
}...)
if i.bastionUserData {
expectedFilenames = append(expectedFilenames,
"aws_s3_bucket_object_nodeupconfig-bastion_content",
"aws_s3_object_nodeupconfig-bastion_content",
"aws_launch_template_bastion."+i.clusterName+"_user_data")
}
}
if i.nth {
expectedFilenames = append(expectedFilenames, []string{
"aws_s3_bucket_object_" + i.clusterName + "-addons-node-termination-handler.aws-k8s-1.11_content",
"aws_s3_object_" + i.clusterName + "-addons-node-termination-handler.aws-k8s-1.11_content",
"aws_cloudwatch_event_rule_" + awsup.GetClusterName40(i.clusterName) + "-ASGLifecycle_event_pattern",
"aws_cloudwatch_event_rule_" + awsup.GetClusterName40(i.clusterName) + "-RebalanceRecommendation_event_pattern",
"aws_cloudwatch_event_rule_" + awsup.GetClusterName40(i.clusterName) + "-SpotInterruption_event_pattern",
@ -1252,28 +1252,28 @@ func (i *integrationTest) runTestTerraformGCE(t *testing.T) {
expectedFilenames = append(expectedFilenames,
"google_compute_instance_template_nodes-"+gce.SafeClusterName(i.clusterName)+"_metadata_startup-script",
"google_compute_instance_template_nodes-"+gce.SafeClusterName(i.clusterName)+"_metadata_ssh-keys",
"aws_s3_bucket_object_cluster-completed.spec_content",
"aws_s3_bucket_object_etcd-cluster-spec-events_content",
"aws_s3_bucket_object_etcd-cluster-spec-main_content",
"aws_s3_bucket_object_kops-version.txt_content",
"aws_s3_bucket_object_manifests-etcdmanager-events_content",
"aws_s3_bucket_object_manifests-etcdmanager-main_content",
"aws_s3_bucket_object_manifests-static-kube-apiserver-healthcheck_content",
"aws_s3_bucket_object_nodeupconfig-nodes_content",
"aws_s3_bucket_object_"+i.clusterName+"-addons-bootstrap_content",
"aws_s3_bucket_object_"+i.clusterName+"-addons-core.addons.k8s.io_content",
"aws_s3_bucket_object_"+i.clusterName+"-addons-coredns.addons.k8s.io-k8s-1.12_content",
"aws_s3_bucket_object_"+i.clusterName+"-addons-kops-controller.addons.k8s.io-k8s-1.16_content",
"aws_s3_bucket_object_"+i.clusterName+"-addons-kubelet-api.rbac.addons.k8s.io-k8s-1.9_content",
"aws_s3_bucket_object_"+i.clusterName+"-addons-limit-range.addons.k8s.io_content",
"aws_s3_bucket_object_"+i.clusterName+"-addons-metadata-proxy.addons.k8s.io-v0.1.12_content",
"aws_s3_bucket_object_"+i.clusterName+"-addons-storage-gce.addons.k8s.io-v1.7.0_content")
"aws_s3_object_cluster-completed.spec_content",
"aws_s3_object_etcd-cluster-spec-events_content",
"aws_s3_object_etcd-cluster-spec-main_content",
"aws_s3_object_kops-version.txt_content",
"aws_s3_object_manifests-etcdmanager-events_content",
"aws_s3_object_manifests-etcdmanager-main_content",
"aws_s3_object_manifests-static-kube-apiserver-healthcheck_content",
"aws_s3_object_nodeupconfig-nodes_content",
"aws_s3_object_"+i.clusterName+"-addons-bootstrap_content",
"aws_s3_object_"+i.clusterName+"-addons-core.addons.k8s.io_content",
"aws_s3_object_"+i.clusterName+"-addons-coredns.addons.k8s.io-k8s-1.12_content",
"aws_s3_object_"+i.clusterName+"-addons-kops-controller.addons.k8s.io-k8s-1.16_content",
"aws_s3_object_"+i.clusterName+"-addons-kubelet-api.rbac.addons.k8s.io-k8s-1.9_content",
"aws_s3_object_"+i.clusterName+"-addons-limit-range.addons.k8s.io_content",
"aws_s3_object_"+i.clusterName+"-addons-metadata-proxy.addons.k8s.io-v0.1.12_content",
"aws_s3_object_"+i.clusterName+"-addons-storage-gce.addons.k8s.io-v1.7.0_content")
for j := 0; j < i.zones; j++ {
zone := "us-test1-" + string([]byte{byte('a') + byte(j)})
prefix := "google_compute_instance_template_master-" + zone + "-" + gce.SafeClusterName(i.clusterName) + "_metadata_"
expectedFilenames = append(expectedFilenames, "aws_s3_bucket_object_nodeupconfig-master-"+zone+"_content")
expectedFilenames = append(expectedFilenames, "aws_s3_object_nodeupconfig-master-"+zone+"_content")
expectedFilenames = append(expectedFilenames, prefix+"startup-script")
expectedFilenames = append(expectedFilenames, prefix+"ssh-keys")
}

View File

@ -251,7 +251,7 @@ terraform {
aws = {
"configuration_aliases" = [aws.files]
"source" = "hashicorp/aws"
"version" = ">= 3.71.0"
"version" = ">= 4.0.0"
}
}
}
@ -326,7 +326,7 @@ terraform {
aws = {
"configuration_aliases" = [aws.files]
"source" = "hashicorp/aws"
"version" = ">= 3.71.0"
"version" = ">= 4.0.0"
}
}
}

View File

@ -99,7 +99,7 @@ terraform {
aws = {
"configuration_aliases" = [aws.files]
"source" = "hashicorp/aws"
"version" = ">= 3.71.0"
"version" = ">= 4.0.0"
}
}
}
@ -186,7 +186,7 @@ terraform {
aws = {
"configuration_aliases" = [aws.files]
"source" = "hashicorp/aws"
"version" = ">= 3.71.0"
"version" = ">= 4.0.0"
}
}
}

View File

@ -122,7 +122,7 @@ func (t *TerraformTarget) finishHCL2() error {
}
writeMap(requiredProvidersBody, "aws", map[string]cty.Value{
"source": cty.StringVal("hashicorp/aws"),
"version": cty.StringVal(">= 3.71.0"),
"version": cty.StringVal(">= 4.0.0"),
"configuration_aliases": aliasesVal,
})
if featureflag.Spotinst.Enabled() {

View File

@ -236,7 +236,7 @@ func (p *MemFSPath) RenderTerraform(w *terraformWriter.TerraformWriter, name str
return fmt.Errorf("reading data: %v", err)
}
content, err := w.AddFileBytes("aws_s3_bucket_object", name, "content", bytes, false)
content, err := w.AddFileBytes("aws_s3_object", name, "content", bytes, false)
if err != nil {
return fmt.Errorf("rendering S3 file: %v", err)
}
@ -258,5 +258,5 @@ func (p *MemFSPath) RenderTerraform(w *terraformWriter.TerraformWriter, name str
Acl: requestAcl,
Provider: terraformWriter.LiteralTokens("aws", "files"),
}
return w.RenderResource("aws_s3_bucket_object", name, tf)
return w.RenderResource("aws_s3_object", name, tf)
}

View File

@ -539,7 +539,7 @@ func (p *S3Path) RenderTerraform(w *terraformWriter.TerraformWriter, name string
return fmt.Errorf("reading data: %v", err)
}
content, err := w.AddFileBytes("aws_s3_bucket_object", name, "content", bytes, false)
content, err := w.AddFileBytes("aws_s3_object", name, "content", bytes, false)
if err != nil {
return fmt.Errorf("rendering S3 file: %v", err)
}
@ -562,7 +562,7 @@ func (p *S3Path) RenderTerraform(w *terraformWriter.TerraformWriter, name string
Acl: requestACL,
Provider: terraformWriter.LiteralTokens("aws", "files"),
}
return w.RenderResource("aws_s3_bucket_object", name, tf)
return w.RenderResource("aws_s3_object", name, tf)
}
// AWSErrorCode returns the aws error code, if it is an awserr.Error, otherwise ""

View File

@ -44,7 +44,7 @@ func TestS3RenderTerraform(t *testing.T) {
{
"acl": "bucket-owner-full-control",
"bucket": "foo",
"content": "${file(\"${path.module}/data/aws_s3_bucket_object_bar_content\")}",
"content": "${file(\"${path.module}/data/aws_s3_object_bar_content\")}",
"key": "bar",
"provider": "${aws.files}",
"server_side_encryption": "AES256"
@ -88,15 +88,15 @@ func TestS3RenderTerraform(t *testing.T) {
t.Fatalf("error fetching terraform resources: %v", err)
t.FailNow()
}
if objs := res["aws_s3_bucket_object"]; objs == nil {
t.Fatalf("aws_s3_bucket_object resources not found: %v", res)
if objs := res["aws_s3_object"]; objs == nil {
t.Fatalf("aws_s3_object resources not found: %v", res)
t.FailNow()
}
if obj := res["aws_s3_bucket_object"][tc.s3Object]; obj == nil {
t.Fatalf("aws_s3_bucket_object object not found: %v", res["aws_s3_bucket_object"])
if obj := res["aws_s3_object"][tc.s3Object]; obj == nil {
t.Fatalf("aws_s3_object object not found: %v", res["aws_s3_object"])
t.FailNow()
}
obj, err := json.Marshal(res["aws_s3_bucket_object"][tc.s3Object])
obj, err := json.Marshal(res["aws_s3_object"][tc.s3Object])
if err != nil {
t.Fatalf("error marshaling s3 object: %v", err)
t.FailNow()
@ -104,12 +104,12 @@ func TestS3RenderTerraform(t *testing.T) {
if !assert.JSONEq(t, tc.expectedJSON, string(obj), "JSON representation of terraform resource did not match") {
t.FailNow()
}
if objs := target.TerraformWriter.Files[fmt.Sprintf("data/aws_s3_bucket_object_%v_content", tc.s3Object)]; objs == nil {
t.Fatalf("aws_s3_bucket_object content file not found: %v", target.TerraformWriter.Files)
if objs := target.TerraformWriter.Files[fmt.Sprintf("data/aws_s3_object_%v_content", tc.s3Object)]; objs == nil {
t.Fatalf("aws_s3_object content file not found: %v", target.TerraformWriter.Files)
t.FailNow()
}
actualContent := string(target.TerraformWriter.Files[fmt.Sprintf("data/aws_s3_bucket_object_%v_content", tc.s3Object)])
if !assert.Equal(t, content, actualContent, "aws_s3_bucket_object content did not match") {
actualContent := string(target.TerraformWriter.Files[fmt.Sprintf("data/aws_s3_object_%v_content", tc.s3Object)])
if !assert.Equal(t, content, actualContent, "aws_s3_object content did not match") {
t.FailNow()
}
})