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_cloudformation_stack fails to update on parameters change #4332

Closed
mtb-xt opened this issue Dec 16, 2015 · 2 comments · Fixed by #4370
Closed

aws_cloudformation_stack fails to update on parameters change #4332

mtb-xt opened this issue Dec 16, 2015 · 2 comments · Fixed by #4370

Comments

@mtb-xt
Copy link

mtb-xt commented Dec 16, 2015

On Terraform v0.6.8 when I change a parameter in a cloudformation stack it fails to update with this error message:

Error applying plan:

1 error(s) occurred:

* aws_cloudformation_stack.redshift-prod: ValidationError: Either Template URL or Template Body must be specified.
    status code: 400, request id: d9699a58-a391-11e5-a7d9-391c1ba71e76

The template looks like this, it's a modified version of a sample Redshift template from AWS. The stack creates just fine, it only fails to update when parameters in terraform are changed, i.e if you change the maintenance window for Redshift.

resource "aws_security_group" "redshift_sg" {
  name = "redshift_sg"
  description = "Allow traffic to Redshift cluster"

    vpc_id = "${aws_vpc.prod.id}"

    // Redshift tcp port
    ingress {
        from_port = 5439
        to_port = 5439
        protocol = "tcp"
        cidr_blocks = ["10.0.0.0/8"]
    }

  tags {
    Name = "redshift_sg"
  }
}

resource "aws_cloudformation_stack" "redshift-prod" {
  name = "redshift-prod"
  parameters { 
    SecurityGroupId = "${aws_security_group.redshift_sg.id}"
    SubnetId = "${aws_subnet.prod-net-b.id}"
    MasterUsername= "loluser"
    MasterUserPassword= "lolmegasecret"
    PreferredMaintenanceWindow = "fri:17:00-fri:18:00"
    AllowVersionUpgrade = "true"
  }
  template_body = <<STACK
{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Parameters" : {
    "DatabaseName" : {
      "Description" : "The name of the first database to be created when the cluster is created",
      "Type" : "String",
      "Default" : "megalol",
      "AllowedPattern" : "([a-z]|[0-9])+"
    },
    "ClusterType" : {
      "Description" : "The type of cluster",
      "Type" : "String",
      "Default" : "single-node",
      "AllowedValues" : [ "single-node", "multi-node" ]
    },
    "NumberOfNodes" : {
      "Description" : "The number of compute nodes in the cluster. For multi-node clusters, the NumberOfNodes parameter must be greater than 1",
      "Type" : "Number",
      "Default" : "1"
    },
    "NodeType" : {
      "Description" : "The type of node to be provisioned",
      "Type" : "String",
      "Default" : "dc1.large",
      "AllowedValues" : [ "dc1.large", "dc1.8xlarge", "ds2.xlarge", "ds2.8xlarge" ]
    }, 
    "MasterUsername" : {
      "Description" : "The user name that is associated with the master user account for the cluster that is being created",
      "Type" : "String",
      "Default" : "defaultuser",
      "AllowedPattern" : "([a-z])([a-z]|[0-9])*"
    },
    "SecurityGroupId" : {
      "Description" : "VPC Security Group id to use for the cluster",
      "Type" : "String"
    },
    "SubnetId" : {
      "Description" : "VPC subnet id to use for the cluster",
      "Type" : "String"
    },
    "PreferredMaintenanceWindow" : {
      "Description" : "The weekly time range (in UTC) during which automated cluster maintenance can occur. The format of the time range is ddd:hh24:mi-ddd:hh24:mi.",
      "Type" : "String"
    },
    "AllowVersionUpgrade" : {
      "Description" : "When a new version of the Amazon Redshift is released, indicates whether upgrades can be applied to the engine that is running on the cluster. The upgrades are applied during the maintenance window.",
      "Type" : "String"
    },
    "MasterUserPassword" :  {
      "Description" : "The password that is associated with the master user account for the cluster that is being created.",
      "Type" : "String"
    },
    "PortNumber" : {
      "Description" : "The port number on which the cluster accepts incoming connections.",
      "Type" : "Number",
      "Default" : "5439"
    }
  },
  "Conditions" : {
    "IsMultiNodeCluster" : {
      "Fn::Equals" : [{ "Ref" : "ClusterType" }, "multi-node" ]        
    }
  },
  "Resources" : {
    "RedshiftCluster" : {
      "Type" : "AWS::Redshift::Cluster",
      "Properties" : {
        "ClusterType" : { "Ref" : "ClusterType" },
        "NumberOfNodes" : { "Fn::If" : [ "IsMultiNodeCluster",  { "Ref" : "NumberOfNodes" }, { "Ref" : "AWS::NoValue" }]},
        "NodeType" : { "Ref" : "NodeType" },
        "DBName" : { "Ref" : "DatabaseName" },
        "MasterUsername" : { "Ref" : "MasterUsername" },
        "PreferredMaintenanceWindow" : { "Ref" : "PreferredMaintenanceWindow" },
        "AllowVersionUpgrade" : { "Ref" : "AllowVersionUpgrade" },
        "MasterUserPassword" : { "Ref" : "MasterUserPassword" },               
        "ClusterParameterGroupName" : { "Ref" : "RedshiftClusterParameterGroup" },
        "VpcSecurityGroupIds" : [ { "Ref" : "SecurityGroupId" } ],
        "ClusterSubnetGroupName" : { "Ref" : "RedshiftClusterSubnetGroup" },
        "PubliclyAccessible" : "false",
        "Port" : { "Ref" : "PortNumber" }
      }
    },
    "RedshiftClusterParameterGroup" : {
      "Type" : "AWS::Redshift::ClusterParameterGroup",
      "Properties" : {
        "Description" : "Cluster parameter group",
        "ParameterGroupFamily" : "redshift-1.0",
        "Parameters" : [{
          "ParameterName" : "enable_user_activity_logging",
          "ParameterValue" : "true"
        }]
      }
    },
    "RedshiftClusterSubnetGroup" : {
      "Type" : "AWS::Redshift::ClusterSubnetGroup",
      "Properties" : {
        "Description" : "Cluster subnet group",
        "SubnetIds" : [ { "Ref" : "SubnetId" } ]
      }
    }
  },
  "Outputs" : {
    "ClusterEndpoint" : {
      "Description" : "Cluster endpoint",
      "Value" : { "Fn::Join" : [ ":", [ { "Fn::GetAtt" : [ "RedshiftCluster", "Endpoint.Address" ] }, { "Fn::GetAtt" : [ "RedshiftCluster", "Endpoint.Port" ] } ] ] }
    },
    "ClusterName" : {
      "Description" : "Name of cluster",
      "Value" : { "Ref" : "RedshiftCluster" }
    },
    "ParameterGroupName" : {
      "Description" : "Name of parameter group",
      "Value" : { "Ref" : "RedshiftClusterParameterGroup" }
    },
    "RedshiftClusterSubnetGroupName" : {
      "Description" : "Name of cluster subnet group",
      "Value" : { "Ref" : "RedshiftClusterSubnetGroup" }
    }
  }
}
STACK
}
radeksimko added a commit to MeredithCorpOSS/terraform that referenced this issue Dec 17, 2015
@radeksimko
Copy link
Member

Reproduced, thanks for the report.

PR is on the way.

@ghost
Copy link

ghost commented Apr 29, 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants