github.com/daveadams/terraform@v0.6.4-0.20160830094355-13ce74975936/builtin/providers/aws/provider.go (about) 1 package aws 2 3 import ( 4 "bytes" 5 "fmt" 6 7 "github.com/hashicorp/terraform/helper/hashcode" 8 "github.com/hashicorp/terraform/helper/mutexkv" 9 "github.com/hashicorp/terraform/helper/schema" 10 "github.com/hashicorp/terraform/terraform" 11 ) 12 13 // Provider returns a terraform.ResourceProvider. 14 func Provider() terraform.ResourceProvider { 15 // TODO: Move the validation to this, requires conditional schemas 16 // TODO: Move the configuration to this, requires validation 17 18 // The actual provider 19 return &schema.Provider{ 20 Schema: map[string]*schema.Schema{ 21 "access_key": &schema.Schema{ 22 Type: schema.TypeString, 23 Optional: true, 24 Default: "", 25 Description: descriptions["access_key"], 26 }, 27 28 "secret_key": &schema.Schema{ 29 Type: schema.TypeString, 30 Optional: true, 31 Default: "", 32 Description: descriptions["secret_key"], 33 }, 34 35 "profile": &schema.Schema{ 36 Type: schema.TypeString, 37 Optional: true, 38 Default: "", 39 Description: descriptions["profile"], 40 }, 41 42 "shared_credentials_file": &schema.Schema{ 43 Type: schema.TypeString, 44 Optional: true, 45 Default: "", 46 Description: descriptions["shared_credentials_file"], 47 }, 48 49 "token": &schema.Schema{ 50 Type: schema.TypeString, 51 Optional: true, 52 Default: "", 53 Description: descriptions["token"], 54 }, 55 56 "region": &schema.Schema{ 57 Type: schema.TypeString, 58 Required: true, 59 DefaultFunc: schema.MultiEnvDefaultFunc([]string{ 60 "AWS_REGION", 61 "AWS_DEFAULT_REGION", 62 }, nil), 63 Description: descriptions["region"], 64 InputDefault: "us-east-1", 65 }, 66 67 "max_retries": &schema.Schema{ 68 Type: schema.TypeInt, 69 Optional: true, 70 Default: 11, 71 Description: descriptions["max_retries"], 72 }, 73 74 "allowed_account_ids": &schema.Schema{ 75 Type: schema.TypeSet, 76 Elem: &schema.Schema{Type: schema.TypeString}, 77 Optional: true, 78 ConflictsWith: []string{"forbidden_account_ids"}, 79 Set: schema.HashString, 80 }, 81 82 "forbidden_account_ids": &schema.Schema{ 83 Type: schema.TypeSet, 84 Elem: &schema.Schema{Type: schema.TypeString}, 85 Optional: true, 86 ConflictsWith: []string{"allowed_account_ids"}, 87 Set: schema.HashString, 88 }, 89 90 "dynamodb_endpoint": &schema.Schema{ 91 Type: schema.TypeString, 92 Optional: true, 93 Default: "", 94 Description: descriptions["dynamodb_endpoint"], 95 }, 96 97 "kinesis_endpoint": &schema.Schema{ 98 Type: schema.TypeString, 99 Optional: true, 100 Default: "", 101 Description: descriptions["kinesis_endpoint"], 102 }, 103 104 "endpoints": endpointsSchema(), 105 106 "insecure": &schema.Schema{ 107 Type: schema.TypeBool, 108 Optional: true, 109 Default: false, 110 Description: descriptions["insecure"], 111 }, 112 113 "skip_credentials_validation": &schema.Schema{ 114 Type: schema.TypeBool, 115 Optional: true, 116 Default: false, 117 Description: descriptions["skip_credentials_validation"], 118 }, 119 120 "skip_requesting_account_id": &schema.Schema{ 121 Type: schema.TypeBool, 122 Optional: true, 123 Default: false, 124 Description: descriptions["skip_requesting_account_id"], 125 }, 126 127 "skip_metadata_api_check": &schema.Schema{ 128 Type: schema.TypeBool, 129 Optional: true, 130 Default: false, 131 Description: descriptions["skip_metadata_api_check"], 132 }, 133 134 "s3_force_path_style": &schema.Schema{ 135 Type: schema.TypeBool, 136 Optional: true, 137 Default: false, 138 Description: descriptions["s3_force_path_style"], 139 }, 140 }, 141 142 DataSourcesMap: map[string]*schema.Resource{ 143 "aws_ami": dataSourceAwsAmi(), 144 "aws_availability_zones": dataSourceAwsAvailabilityZones(), 145 "aws_caller_identity": dataSourceAwsCallerIdentity(), 146 "aws_ecs_container_definition": dataSourceAwsEcsContainerDefinition(), 147 "aws_elb_service_account": dataSourceAwsElbServiceAccount(), 148 "aws_iam_policy_document": dataSourceAwsIamPolicyDocument(), 149 "aws_ip_ranges": dataSourceAwsIPRanges(), 150 "aws_redshift_service_account": dataSourceAwsRedshiftServiceAccount(), 151 "aws_s3_bucket_object": dataSourceAwsS3BucketObject(), 152 }, 153 154 ResourcesMap: map[string]*schema.Resource{ 155 "aws_alb": resourceAwsAlb(), 156 "aws_alb_listener": resourceAwsAlbListener(), 157 "aws_alb_listener_rule": resourceAwsAlbListenerRule(), 158 "aws_alb_target_group": resourceAwsAlbTargetGroup(), 159 "aws_alb_target_group_attachment": resourceAwsAlbTargetGroupAttachment(), 160 "aws_ami": resourceAwsAmi(), 161 "aws_ami_copy": resourceAwsAmiCopy(), 162 "aws_ami_from_instance": resourceAwsAmiFromInstance(), 163 "aws_ami_launch_permission": resourceAwsAmiLaunchPermission(), 164 "aws_api_gateway_account": resourceAwsApiGatewayAccount(), 165 "aws_api_gateway_api_key": resourceAwsApiGatewayApiKey(), 166 "aws_api_gateway_authorizer": resourceAwsApiGatewayAuthorizer(), 167 "aws_api_gateway_base_path_mapping": resourceAwsApiGatewayBasePathMapping(), 168 "aws_api_gateway_deployment": resourceAwsApiGatewayDeployment(), 169 "aws_api_gateway_domain_name": resourceAwsApiGatewayDomainName(), 170 "aws_api_gateway_integration": resourceAwsApiGatewayIntegration(), 171 "aws_api_gateway_integration_response": resourceAwsApiGatewayIntegrationResponse(), 172 "aws_api_gateway_method": resourceAwsApiGatewayMethod(), 173 "aws_api_gateway_method_response": resourceAwsApiGatewayMethodResponse(), 174 "aws_api_gateway_model": resourceAwsApiGatewayModel(), 175 "aws_api_gateway_resource": resourceAwsApiGatewayResource(), 176 "aws_api_gateway_rest_api": resourceAwsApiGatewayRestApi(), 177 "aws_app_cookie_stickiness_policy": resourceAwsAppCookieStickinessPolicy(), 178 "aws_appautoscaling_target": resourceAwsAppautoscalingTarget(), 179 "aws_appautoscaling_policy": resourceAwsAppautoscalingPolicy(), 180 "aws_autoscaling_group": resourceAwsAutoscalingGroup(), 181 "aws_autoscaling_notification": resourceAwsAutoscalingNotification(), 182 "aws_autoscaling_policy": resourceAwsAutoscalingPolicy(), 183 "aws_autoscaling_schedule": resourceAwsAutoscalingSchedule(), 184 "aws_cloudformation_stack": resourceAwsCloudFormationStack(), 185 "aws_cloudfront_distribution": resourceAwsCloudFrontDistribution(), 186 "aws_cloudfront_origin_access_identity": resourceAwsCloudFrontOriginAccessIdentity(), 187 "aws_cloudtrail": resourceAwsCloudTrail(), 188 "aws_cloudwatch_event_rule": resourceAwsCloudWatchEventRule(), 189 "aws_cloudwatch_event_target": resourceAwsCloudWatchEventTarget(), 190 "aws_cloudwatch_log_group": resourceAwsCloudWatchLogGroup(), 191 "aws_cloudwatch_log_metric_filter": resourceAwsCloudWatchLogMetricFilter(), 192 "aws_cloudwatch_log_subscription_filter": resourceAwsCloudwatchLogSubscriptionFilter(), 193 "aws_autoscaling_lifecycle_hook": resourceAwsAutoscalingLifecycleHook(), 194 "aws_cloudwatch_metric_alarm": resourceAwsCloudWatchMetricAlarm(), 195 "aws_codedeploy_app": resourceAwsCodeDeployApp(), 196 "aws_codedeploy_deployment_group": resourceAwsCodeDeployDeploymentGroup(), 197 "aws_codecommit_repository": resourceAwsCodeCommitRepository(), 198 "aws_customer_gateway": resourceAwsCustomerGateway(), 199 "aws_db_event_subscription": resourceAwsDbEventSubscription(), 200 "aws_db_instance": resourceAwsDbInstance(), 201 "aws_db_option_group": resourceAwsDbOptionGroup(), 202 "aws_db_parameter_group": resourceAwsDbParameterGroup(), 203 "aws_db_security_group": resourceAwsDbSecurityGroup(), 204 "aws_db_subnet_group": resourceAwsDbSubnetGroup(), 205 "aws_directory_service_directory": resourceAwsDirectoryServiceDirectory(), 206 "aws_dynamodb_table": resourceAwsDynamoDbTable(), 207 "aws_ebs_volume": resourceAwsEbsVolume(), 208 "aws_ecr_repository": resourceAwsEcrRepository(), 209 "aws_ecr_repository_policy": resourceAwsEcrRepositoryPolicy(), 210 "aws_ecs_cluster": resourceAwsEcsCluster(), 211 "aws_ecs_service": resourceAwsEcsService(), 212 "aws_ecs_task_definition": resourceAwsEcsTaskDefinition(), 213 "aws_efs_file_system": resourceAwsEfsFileSystem(), 214 "aws_efs_mount_target": resourceAwsEfsMountTarget(), 215 "aws_eip": resourceAwsEip(), 216 "aws_eip_association": resourceAwsEipAssociation(), 217 "aws_elasticache_cluster": resourceAwsElasticacheCluster(), 218 "aws_elasticache_parameter_group": resourceAwsElasticacheParameterGroup(), 219 "aws_elasticache_replication_group": resourceAwsElasticacheReplicationGroup(), 220 "aws_elasticache_security_group": resourceAwsElasticacheSecurityGroup(), 221 "aws_elasticache_subnet_group": resourceAwsElasticacheSubnetGroup(), 222 "aws_elastic_beanstalk_application": resourceAwsElasticBeanstalkApplication(), 223 "aws_elastic_beanstalk_configuration_template": resourceAwsElasticBeanstalkConfigurationTemplate(), 224 "aws_elastic_beanstalk_environment": resourceAwsElasticBeanstalkEnvironment(), 225 "aws_elasticsearch_domain": resourceAwsElasticSearchDomain(), 226 "aws_elastictranscoder_pipeline": resourceAwsElasticTranscoderPipeline(), 227 "aws_elastictranscoder_preset": resourceAwsElasticTranscoderPreset(), 228 "aws_elb": resourceAwsElb(), 229 "aws_elb_attachment": resourceAwsElbAttachment(), 230 "aws_flow_log": resourceAwsFlowLog(), 231 "aws_glacier_vault": resourceAwsGlacierVault(), 232 "aws_iam_access_key": resourceAwsIamAccessKey(), 233 "aws_iam_account_password_policy": resourceAwsIamAccountPasswordPolicy(), 234 "aws_iam_group_policy": resourceAwsIamGroupPolicy(), 235 "aws_iam_group": resourceAwsIamGroup(), 236 "aws_iam_group_membership": resourceAwsIamGroupMembership(), 237 "aws_iam_group_policy_attachment": resourceAwsIamGroupPolicyAttachment(), 238 "aws_iam_instance_profile": resourceAwsIamInstanceProfile(), 239 "aws_iam_policy": resourceAwsIamPolicy(), 240 "aws_iam_policy_attachment": resourceAwsIamPolicyAttachment(), 241 "aws_iam_role_policy_attachment": resourceAwsIamRolePolicyAttachment(), 242 "aws_iam_role_policy": resourceAwsIamRolePolicy(), 243 "aws_iam_role": resourceAwsIamRole(), 244 "aws_iam_saml_provider": resourceAwsIamSamlProvider(), 245 "aws_iam_server_certificate": resourceAwsIAMServerCertificate(), 246 "aws_iam_user_policy_attachment": resourceAwsIamUserPolicyAttachment(), 247 "aws_iam_user_policy": resourceAwsIamUserPolicy(), 248 "aws_iam_user_ssh_key": resourceAwsIamUserSshKey(), 249 "aws_iam_user": resourceAwsIamUser(), 250 "aws_instance": resourceAwsInstance(), 251 "aws_internet_gateway": resourceAwsInternetGateway(), 252 "aws_key_pair": resourceAwsKeyPair(), 253 "aws_kinesis_firehose_delivery_stream": resourceAwsKinesisFirehoseDeliveryStream(), 254 "aws_kinesis_stream": resourceAwsKinesisStream(), 255 "aws_kms_alias": resourceAwsKmsAlias(), 256 "aws_kms_key": resourceAwsKmsKey(), 257 "aws_lambda_function": resourceAwsLambdaFunction(), 258 "aws_lambda_event_source_mapping": resourceAwsLambdaEventSourceMapping(), 259 "aws_lambda_alias": resourceAwsLambdaAlias(), 260 "aws_lambda_permission": resourceAwsLambdaPermission(), 261 "aws_launch_configuration": resourceAwsLaunchConfiguration(), 262 "aws_lb_cookie_stickiness_policy": resourceAwsLBCookieStickinessPolicy(), 263 "aws_load_balancer_policy": resourceAwsLoadBalancerPolicy(), 264 "aws_load_balancer_backend_server_policy": resourceAwsLoadBalancerBackendServerPolicies(), 265 "aws_load_balancer_listener_policy": resourceAwsLoadBalancerListenerPolicies(), 266 "aws_lb_ssl_negotiation_policy": resourceAwsLBSSLNegotiationPolicy(), 267 "aws_main_route_table_association": resourceAwsMainRouteTableAssociation(), 268 "aws_nat_gateway": resourceAwsNatGateway(), 269 "aws_network_acl": resourceAwsNetworkAcl(), 270 "aws_default_network_acl": resourceAwsDefaultNetworkAcl(), 271 "aws_default_route_table": resourceAwsDefaultRouteTable(), 272 "aws_network_acl_rule": resourceAwsNetworkAclRule(), 273 "aws_network_interface": resourceAwsNetworkInterface(), 274 "aws_opsworks_application": resourceAwsOpsworksApplication(), 275 "aws_opsworks_stack": resourceAwsOpsworksStack(), 276 "aws_opsworks_java_app_layer": resourceAwsOpsworksJavaAppLayer(), 277 "aws_opsworks_haproxy_layer": resourceAwsOpsworksHaproxyLayer(), 278 "aws_opsworks_static_web_layer": resourceAwsOpsworksStaticWebLayer(), 279 "aws_opsworks_php_app_layer": resourceAwsOpsworksPhpAppLayer(), 280 "aws_opsworks_rails_app_layer": resourceAwsOpsworksRailsAppLayer(), 281 "aws_opsworks_nodejs_app_layer": resourceAwsOpsworksNodejsAppLayer(), 282 "aws_opsworks_memcached_layer": resourceAwsOpsworksMemcachedLayer(), 283 "aws_opsworks_mysql_layer": resourceAwsOpsworksMysqlLayer(), 284 "aws_opsworks_ganglia_layer": resourceAwsOpsworksGangliaLayer(), 285 "aws_opsworks_custom_layer": resourceAwsOpsworksCustomLayer(), 286 "aws_opsworks_instance": resourceAwsOpsworksInstance(), 287 "aws_opsworks_user_profile": resourceAwsOpsworksUserProfile(), 288 "aws_opsworks_permission": resourceAwsOpsworksPermission(), 289 "aws_placement_group": resourceAwsPlacementGroup(), 290 "aws_proxy_protocol_policy": resourceAwsProxyProtocolPolicy(), 291 "aws_rds_cluster": resourceAwsRDSCluster(), 292 "aws_rds_cluster_instance": resourceAwsRDSClusterInstance(), 293 "aws_rds_cluster_parameter_group": resourceAwsRDSClusterParameterGroup(), 294 "aws_redshift_cluster": resourceAwsRedshiftCluster(), 295 "aws_redshift_security_group": resourceAwsRedshiftSecurityGroup(), 296 "aws_redshift_parameter_group": resourceAwsRedshiftParameterGroup(), 297 "aws_redshift_subnet_group": resourceAwsRedshiftSubnetGroup(), 298 "aws_route53_delegation_set": resourceAwsRoute53DelegationSet(), 299 "aws_route53_record": resourceAwsRoute53Record(), 300 "aws_route53_zone_association": resourceAwsRoute53ZoneAssociation(), 301 "aws_route53_zone": resourceAwsRoute53Zone(), 302 "aws_route53_health_check": resourceAwsRoute53HealthCheck(), 303 "aws_route": resourceAwsRoute(), 304 "aws_route_table": resourceAwsRouteTable(), 305 "aws_route_table_association": resourceAwsRouteTableAssociation(), 306 "aws_ses_active_receipt_rule_set": resourceAwsSesActiveReceiptRuleSet(), 307 "aws_ses_receipt_filter": resourceAwsSesReceiptFilter(), 308 "aws_ses_receipt_rule": resourceAwsSesReceiptRule(), 309 "aws_ses_receipt_rule_set": resourceAwsSesReceiptRuleSet(), 310 "aws_s3_bucket": resourceAwsS3Bucket(), 311 "aws_s3_bucket_object": resourceAwsS3BucketObject(), 312 "aws_s3_bucket_notification": resourceAwsS3BucketNotification(), 313 "aws_security_group": resourceAwsSecurityGroup(), 314 "aws_security_group_rule": resourceAwsSecurityGroupRule(), 315 "aws_simpledb_domain": resourceAwsSimpleDBDomain(), 316 "aws_ssm_document": resourceAwsSsmDocument(), 317 "aws_spot_instance_request": resourceAwsSpotInstanceRequest(), 318 "aws_spot_fleet_request": resourceAwsSpotFleetRequest(), 319 "aws_sqs_queue": resourceAwsSqsQueue(), 320 "aws_sns_topic": resourceAwsSnsTopic(), 321 "aws_sns_topic_subscription": resourceAwsSnsTopicSubscription(), 322 "aws_subnet": resourceAwsSubnet(), 323 "aws_volume_attachment": resourceAwsVolumeAttachment(), 324 "aws_vpc_dhcp_options_association": resourceAwsVpcDhcpOptionsAssociation(), 325 "aws_vpc_dhcp_options": resourceAwsVpcDhcpOptions(), 326 "aws_vpc_peering_connection": resourceAwsVpcPeeringConnection(), 327 "aws_vpc": resourceAwsVpc(), 328 "aws_vpc_endpoint": resourceAwsVpcEndpoint(), 329 "aws_vpn_connection": resourceAwsVpnConnection(), 330 "aws_vpn_connection_route": resourceAwsVpnConnectionRoute(), 331 "aws_vpn_gateway": resourceAwsVpnGateway(), 332 "aws_vpn_gateway_attachment": resourceAwsVpnGatewayAttachment(), 333 }, 334 ConfigureFunc: providerConfigure, 335 } 336 } 337 338 var descriptions map[string]string 339 340 func init() { 341 descriptions = map[string]string{ 342 "region": "The region where AWS operations will take place. Examples\n" + 343 "are us-east-1, us-west-2, etc.", 344 345 "access_key": "The access key for API operations. You can retrieve this\n" + 346 "from the 'Security & Credentials' section of the AWS console.", 347 348 "secret_key": "The secret key for API operations. You can retrieve this\n" + 349 "from the 'Security & Credentials' section of the AWS console.", 350 351 "profile": "The profile for API operations. If not set, the default profile\n" + 352 "created with `aws configure` will be used.", 353 354 "shared_credentials_file": "The path to the shared credentials file. If not set\n" + 355 "this defaults to ~/.aws/credentials.", 356 357 "token": "session token. A session token is only required if you are\n" + 358 "using temporary security credentials.", 359 360 "max_retries": "The maximum number of times an AWS API request is\n" + 361 "being executed. If the API request still fails, an error is\n" + 362 "thrown.", 363 364 "dynamodb_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n" + 365 "It's typically used to connect to dynamodb-local.", 366 367 "kinesis_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n" + 368 "It's typically used to connect to kinesalite.", 369 370 "iam_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", 371 372 "ec2_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", 373 374 "elb_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", 375 376 "s3_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", 377 378 "insecure": "Explicitly allow the provider to perform \"insecure\" SSL requests. If omitted," + 379 "default value is `false`", 380 381 "skip_credentials_validation": "Skip the credentials validation via STS API. " + 382 "Used for AWS API implementations that do not have STS available/implemented.", 383 384 "skip_requesting_account_id": "Skip requesting the account ID. " + 385 "Used for AWS API implementations that do not have IAM/STS API and/or metadata API.", 386 387 "skip_medatadata_api_check": "Skip the AWS Metadata API check. " + 388 "Used for AWS API implementations that do not have a metadata api endpoint.", 389 390 "s3_force_path_style": "Set this to true to force the request to use path-style addressing,\n" + 391 "i.e., http://s3.amazonaws.com/BUCKET/KEY. By default, the S3 client will\n" + 392 "use virtual hosted bucket addressing when possible\n" + 393 "(http://BUCKET.s3.amazonaws.com/KEY). Specific to the Amazon S3 service.", 394 } 395 } 396 397 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 398 config := Config{ 399 AccessKey: d.Get("access_key").(string), 400 SecretKey: d.Get("secret_key").(string), 401 Profile: d.Get("profile").(string), 402 CredsFilename: d.Get("shared_credentials_file").(string), 403 Token: d.Get("token").(string), 404 Region: d.Get("region").(string), 405 MaxRetries: d.Get("max_retries").(int), 406 DynamoDBEndpoint: d.Get("dynamodb_endpoint").(string), 407 KinesisEndpoint: d.Get("kinesis_endpoint").(string), 408 Insecure: d.Get("insecure").(bool), 409 SkipCredsValidation: d.Get("skip_credentials_validation").(bool), 410 SkipRequestingAccountId: d.Get("skip_requesting_account_id").(bool), 411 SkipMetadataApiCheck: d.Get("skip_metadata_api_check").(bool), 412 S3ForcePathStyle: d.Get("s3_force_path_style").(bool), 413 } 414 415 endpointsSet := d.Get("endpoints").(*schema.Set) 416 417 for _, endpointsSetI := range endpointsSet.List() { 418 endpoints := endpointsSetI.(map[string]interface{}) 419 config.IamEndpoint = endpoints["iam"].(string) 420 config.Ec2Endpoint = endpoints["ec2"].(string) 421 config.ElbEndpoint = endpoints["elb"].(string) 422 config.S3Endpoint = endpoints["s3"].(string) 423 } 424 425 if v, ok := d.GetOk("allowed_account_ids"); ok { 426 config.AllowedAccountIds = v.(*schema.Set).List() 427 } 428 429 if v, ok := d.GetOk("forbidden_account_ids"); ok { 430 config.ForbiddenAccountIds = v.(*schema.Set).List() 431 } 432 433 return config.Client() 434 } 435 436 // This is a global MutexKV for use within this plugin. 437 var awsMutexKV = mutexkv.NewMutexKV() 438 439 func endpointsSchema() *schema.Schema { 440 return &schema.Schema{ 441 Type: schema.TypeSet, 442 Optional: true, 443 Elem: &schema.Resource{ 444 Schema: map[string]*schema.Schema{ 445 "iam": &schema.Schema{ 446 Type: schema.TypeString, 447 Optional: true, 448 Default: "", 449 Description: descriptions["iam_endpoint"], 450 }, 451 452 "ec2": &schema.Schema{ 453 Type: schema.TypeString, 454 Optional: true, 455 Default: "", 456 Description: descriptions["ec2_endpoint"], 457 }, 458 459 "elb": &schema.Schema{ 460 Type: schema.TypeString, 461 Optional: true, 462 Default: "", 463 Description: descriptions["elb_endpoint"], 464 }, 465 "s3": &schema.Schema{ 466 Type: schema.TypeString, 467 Optional: true, 468 Default: "", 469 Description: descriptions["s3_endpoint"], 470 }, 471 }, 472 }, 473 Set: endpointsToHash, 474 } 475 } 476 477 func endpointsToHash(v interface{}) int { 478 var buf bytes.Buffer 479 m := v.(map[string]interface{}) 480 buf.WriteString(fmt.Sprintf("%s-", m["iam"].(string))) 481 buf.WriteString(fmt.Sprintf("%s-", m["ec2"].(string))) 482 buf.WriteString(fmt.Sprintf("%s-", m["elb"].(string))) 483 buf.WriteString(fmt.Sprintf("%s-", m["s3"].(string))) 484 485 return hashcode.String(buf.String()) 486 }