Often, I find myself starting up an AWS cluster, but have forgotten to assign an Elastic IP. However, you cannot change the IP in the AWS console without shutting down and restoring the cluster(a lengthy process)
$ aws redshift modify-cluster --cluster-identifier CLUSTER --elastic-ip IP
An error occurred (InvalidParameterCombination) when calling the ModifyCluster operation: The request to attach the Elastic IP address must include setting PubliclyAccessible to true.
$ aws redshift modify-cluster --cluster-identifier CLUSTER --elastic-ip IP --publicly-accessible
An error occurred (InvalidClusterState) when calling the ModifyCluster operation: The cluster is already publicly accessible.
This is quite the Catch-22 - You can’t modify it unless you’re setting it to --publicly-accessible
and you can’t set it to --publicly-accessible
unless because you’ve already set it! However, there is a hack around it:
$ aws redshift modify-cluster --cluster-identifier CLUSTER --no-publicly-accessible
$ aws redshift modify-cluster --cluster-identifier CLUSTER --elastic-ip IP --publicly-accessible
You reassign the IP by turning off --publicly-accessible
, and then assigning the Elastic IP while setting --publicly-accessible
at the same time.