github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/builtin/providers/aws/provider.go (about) 1 package aws 2 3 import ( 4 "bytes" 5 "fmt" 6 "log" 7 8 "github.com/hashicorp/terraform/helper/hashcode" 9 "github.com/hashicorp/terraform/helper/mutexkv" 10 "github.com/hashicorp/terraform/helper/schema" 11 "github.com/hashicorp/terraform/terraform" 12 ) 13 14 // Provider returns a terraform.ResourceProvider. 15 func Provider() terraform.ResourceProvider { 16 // TODO: Move the validation to this, requires conditional schemas 17 // TODO: Move the configuration to this, requires validation 18 19 // The actual provider 20 return &schema.Provider{ 21 Schema: map[string]*schema.Schema{ 22 "access_key": { 23 Type: schema.TypeString, 24 Optional: true, 25 Default: "", 26 Description: descriptions["access_key"], 27 }, 28 29 "secret_key": { 30 Type: schema.TypeString, 31 Optional: true, 32 Default: "", 33 Description: descriptions["secret_key"], 34 }, 35 36 "profile": { 37 Type: schema.TypeString, 38 Optional: true, 39 Default: "", 40 Description: descriptions["profile"], 41 }, 42 43 "assume_role": assumeRoleSchema(), 44 45 "shared_credentials_file": { 46 Type: schema.TypeString, 47 Optional: true, 48 Default: "", 49 Description: descriptions["shared_credentials_file"], 50 }, 51 52 "token": { 53 Type: schema.TypeString, 54 Optional: true, 55 Default: "", 56 Description: descriptions["token"], 57 }, 58 59 "region": { 60 Type: schema.TypeString, 61 Required: true, 62 DefaultFunc: schema.MultiEnvDefaultFunc([]string{ 63 "AWS_REGION", 64 "AWS_DEFAULT_REGION", 65 }, nil), 66 Description: descriptions["region"], 67 InputDefault: "us-east-1", 68 }, 69 70 "max_retries": { 71 Type: schema.TypeInt, 72 Optional: true, 73 Default: 11, 74 Description: descriptions["max_retries"], 75 }, 76 77 "allowed_account_ids": { 78 Type: schema.TypeSet, 79 Elem: &schema.Schema{Type: schema.TypeString}, 80 Optional: true, 81 ConflictsWith: []string{"forbidden_account_ids"}, 82 Set: schema.HashString, 83 }, 84 85 "forbidden_account_ids": { 86 Type: schema.TypeSet, 87 Elem: &schema.Schema{Type: schema.TypeString}, 88 Optional: true, 89 ConflictsWith: []string{"allowed_account_ids"}, 90 Set: schema.HashString, 91 }, 92 93 "dynamodb_endpoint": { 94 Type: schema.TypeString, 95 Optional: true, 96 Default: "", 97 Description: descriptions["dynamodb_endpoint"], 98 Removed: "Use `dynamodb` inside `endpoints` block instead", 99 }, 100 101 "kinesis_endpoint": { 102 Type: schema.TypeString, 103 Optional: true, 104 Default: "", 105 Description: descriptions["kinesis_endpoint"], 106 Removed: "Use `kinesis` inside `endpoints` block instead", 107 }, 108 109 "endpoints": endpointsSchema(), 110 111 "insecure": { 112 Type: schema.TypeBool, 113 Optional: true, 114 Default: false, 115 Description: descriptions["insecure"], 116 }, 117 118 "skip_credentials_validation": { 119 Type: schema.TypeBool, 120 Optional: true, 121 Default: false, 122 Description: descriptions["skip_credentials_validation"], 123 }, 124 125 "skip_region_validation": { 126 Type: schema.TypeBool, 127 Optional: true, 128 Default: false, 129 Description: descriptions["skip_region_validation"], 130 }, 131 132 "skip_requesting_account_id": { 133 Type: schema.TypeBool, 134 Optional: true, 135 Default: false, 136 Description: descriptions["skip_requesting_account_id"], 137 }, 138 139 "skip_metadata_api_check": { 140 Type: schema.TypeBool, 141 Optional: true, 142 Default: false, 143 Description: descriptions["skip_metadata_api_check"], 144 }, 145 146 "s3_force_path_style": { 147 Type: schema.TypeBool, 148 Optional: true, 149 Default: false, 150 Description: descriptions["s3_force_path_style"], 151 }, 152 }, 153 154 DataSourcesMap: map[string]*schema.Resource{ 155 "aws_acm_certificate": dataSourceAwsAcmCertificate(), 156 "aws_alb": dataSourceAwsAlb(), 157 "aws_alb_listener": dataSourceAwsAlbListener(), 158 "aws_ami": dataSourceAwsAmi(), 159 "aws_autoscaling_groups": dataSourceAwsAutoscalingGroups(), 160 "aws_availability_zone": dataSourceAwsAvailabilityZone(), 161 "aws_availability_zones": dataSourceAwsAvailabilityZones(), 162 "aws_billing_service_account": dataSourceAwsBillingServiceAccount(), 163 "aws_caller_identity": dataSourceAwsCallerIdentity(), 164 "aws_canonical_user_id": dataSourceAwsCanonicalUserId(), 165 "aws_cloudformation_stack": dataSourceAwsCloudFormationStack(), 166 "aws_db_instance": dataSourceAwsDbInstance(), 167 "aws_ebs_snapshot": dataSourceAwsEbsSnapshot(), 168 "aws_ebs_volume": dataSourceAwsEbsVolume(), 169 "aws_ecs_cluster": dataSourceAwsEcsCluster(), 170 "aws_ecs_container_definition": dataSourceAwsEcsContainerDefinition(), 171 "aws_ecs_task_definition": dataSourceAwsEcsTaskDefinition(), 172 "aws_eip": dataSourceAwsEip(), 173 "aws_elb_hosted_zone_id": dataSourceAwsElbHostedZoneId(), 174 "aws_elb_service_account": dataSourceAwsElbServiceAccount(), 175 "aws_iam_account_alias": dataSourceAwsIamAccountAlias(), 176 "aws_iam_policy_document": dataSourceAwsIamPolicyDocument(), 177 "aws_iam_server_certificate": dataSourceAwsIAMServerCertificate(), 178 "aws_instance": dataSourceAwsInstance(), 179 "aws_ip_ranges": dataSourceAwsIPRanges(), 180 "aws_kms_secret": dataSourceAwsKmsSecret(), 181 "aws_partition": dataSourceAwsPartition(), 182 "aws_prefix_list": dataSourceAwsPrefixList(), 183 "aws_redshift_service_account": dataSourceAwsRedshiftServiceAccount(), 184 "aws_region": dataSourceAwsRegion(), 185 "aws_route_table": dataSourceAwsRouteTable(), 186 "aws_route53_zone": dataSourceAwsRoute53Zone(), 187 "aws_s3_bucket_object": dataSourceAwsS3BucketObject(), 188 "aws_sns_topic": dataSourceAwsSnsTopic(), 189 "aws_subnet": dataSourceAwsSubnet(), 190 "aws_security_group": dataSourceAwsSecurityGroup(), 191 "aws_vpc": dataSourceAwsVpc(), 192 "aws_vpc_endpoint": dataSourceAwsVpcEndpoint(), 193 "aws_vpc_endpoint_service": dataSourceAwsVpcEndpointService(), 194 "aws_vpc_peering_connection": dataSourceAwsVpcPeeringConnection(), 195 "aws_vpn_gateway": dataSourceAwsVpnGateway(), 196 }, 197 198 ResourcesMap: map[string]*schema.Resource{ 199 "aws_alb": resourceAwsAlb(), 200 "aws_alb_listener": resourceAwsAlbListener(), 201 "aws_alb_listener_rule": resourceAwsAlbListenerRule(), 202 "aws_alb_target_group": resourceAwsAlbTargetGroup(), 203 "aws_alb_target_group_attachment": resourceAwsAlbTargetGroupAttachment(), 204 "aws_ami": resourceAwsAmi(), 205 "aws_ami_copy": resourceAwsAmiCopy(), 206 "aws_ami_from_instance": resourceAwsAmiFromInstance(), 207 "aws_ami_launch_permission": resourceAwsAmiLaunchPermission(), 208 "aws_api_gateway_account": resourceAwsApiGatewayAccount(), 209 "aws_api_gateway_api_key": resourceAwsApiGatewayApiKey(), 210 "aws_api_gateway_authorizer": resourceAwsApiGatewayAuthorizer(), 211 "aws_api_gateway_base_path_mapping": resourceAwsApiGatewayBasePathMapping(), 212 "aws_api_gateway_client_certificate": resourceAwsApiGatewayClientCertificate(), 213 "aws_api_gateway_deployment": resourceAwsApiGatewayDeployment(), 214 "aws_api_gateway_domain_name": resourceAwsApiGatewayDomainName(), 215 "aws_api_gateway_integration": resourceAwsApiGatewayIntegration(), 216 "aws_api_gateway_integration_response": resourceAwsApiGatewayIntegrationResponse(), 217 "aws_api_gateway_method": resourceAwsApiGatewayMethod(), 218 "aws_api_gateway_method_response": resourceAwsApiGatewayMethodResponse(), 219 "aws_api_gateway_model": resourceAwsApiGatewayModel(), 220 "aws_api_gateway_resource": resourceAwsApiGatewayResource(), 221 "aws_api_gateway_rest_api": resourceAwsApiGatewayRestApi(), 222 "aws_app_cookie_stickiness_policy": resourceAwsAppCookieStickinessPolicy(), 223 "aws_appautoscaling_target": resourceAwsAppautoscalingTarget(), 224 "aws_appautoscaling_policy": resourceAwsAppautoscalingPolicy(), 225 "aws_autoscaling_attachment": resourceAwsAutoscalingAttachment(), 226 "aws_autoscaling_group": resourceAwsAutoscalingGroup(), 227 "aws_autoscaling_notification": resourceAwsAutoscalingNotification(), 228 "aws_autoscaling_policy": resourceAwsAutoscalingPolicy(), 229 "aws_autoscaling_schedule": resourceAwsAutoscalingSchedule(), 230 "aws_cloudformation_stack": resourceAwsCloudFormationStack(), 231 "aws_cloudfront_distribution": resourceAwsCloudFrontDistribution(), 232 "aws_cloudfront_origin_access_identity": resourceAwsCloudFrontOriginAccessIdentity(), 233 "aws_cloudtrail": resourceAwsCloudTrail(), 234 "aws_cloudwatch_event_rule": resourceAwsCloudWatchEventRule(), 235 "aws_cloudwatch_event_target": resourceAwsCloudWatchEventTarget(), 236 "aws_cloudwatch_log_destination": resourceAwsCloudWatchLogDestination(), 237 "aws_cloudwatch_log_destination_policy": resourceAwsCloudWatchLogDestinationPolicy(), 238 "aws_cloudwatch_log_group": resourceAwsCloudWatchLogGroup(), 239 "aws_cloudwatch_log_metric_filter": resourceAwsCloudWatchLogMetricFilter(), 240 "aws_cloudwatch_log_stream": resourceAwsCloudWatchLogStream(), 241 "aws_cloudwatch_log_subscription_filter": resourceAwsCloudwatchLogSubscriptionFilter(), 242 "aws_config_config_rule": resourceAwsConfigConfigRule(), 243 "aws_config_configuration_recorder": resourceAwsConfigConfigurationRecorder(), 244 "aws_config_configuration_recorder_status": resourceAwsConfigConfigurationRecorderStatus(), 245 "aws_config_delivery_channel": resourceAwsConfigDeliveryChannel(), 246 "aws_autoscaling_lifecycle_hook": resourceAwsAutoscalingLifecycleHook(), 247 "aws_cloudwatch_metric_alarm": resourceAwsCloudWatchMetricAlarm(), 248 "aws_codedeploy_app": resourceAwsCodeDeployApp(), 249 "aws_codedeploy_deployment_config": resourceAwsCodeDeployDeploymentConfig(), 250 "aws_codedeploy_deployment_group": resourceAwsCodeDeployDeploymentGroup(), 251 "aws_codecommit_repository": resourceAwsCodeCommitRepository(), 252 "aws_codecommit_trigger": resourceAwsCodeCommitTrigger(), 253 "aws_codebuild_project": resourceAwsCodeBuildProject(), 254 "aws_codepipeline": resourceAwsCodePipeline(), 255 "aws_customer_gateway": resourceAwsCustomerGateway(), 256 "aws_db_event_subscription": resourceAwsDbEventSubscription(), 257 "aws_db_instance": resourceAwsDbInstance(), 258 "aws_db_option_group": resourceAwsDbOptionGroup(), 259 "aws_db_parameter_group": resourceAwsDbParameterGroup(), 260 "aws_db_security_group": resourceAwsDbSecurityGroup(), 261 "aws_db_subnet_group": resourceAwsDbSubnetGroup(), 262 "aws_directory_service_directory": resourceAwsDirectoryServiceDirectory(), 263 "aws_dms_certificate": resourceAwsDmsCertificate(), 264 "aws_dms_endpoint": resourceAwsDmsEndpoint(), 265 "aws_dms_replication_instance": resourceAwsDmsReplicationInstance(), 266 "aws_dms_replication_subnet_group": resourceAwsDmsReplicationSubnetGroup(), 267 "aws_dms_replication_task": resourceAwsDmsReplicationTask(), 268 "aws_dynamodb_table": resourceAwsDynamoDbTable(), 269 "aws_ebs_snapshot": resourceAwsEbsSnapshot(), 270 "aws_ebs_volume": resourceAwsEbsVolume(), 271 "aws_ecr_repository": resourceAwsEcrRepository(), 272 "aws_ecr_repository_policy": resourceAwsEcrRepositoryPolicy(), 273 "aws_ecs_cluster": resourceAwsEcsCluster(), 274 "aws_ecs_service": resourceAwsEcsService(), 275 "aws_ecs_task_definition": resourceAwsEcsTaskDefinition(), 276 "aws_efs_file_system": resourceAwsEfsFileSystem(), 277 "aws_efs_mount_target": resourceAwsEfsMountTarget(), 278 "aws_egress_only_internet_gateway": resourceAwsEgressOnlyInternetGateway(), 279 "aws_eip": resourceAwsEip(), 280 "aws_eip_association": resourceAwsEipAssociation(), 281 "aws_elasticache_cluster": resourceAwsElasticacheCluster(), 282 "aws_elasticache_parameter_group": resourceAwsElasticacheParameterGroup(), 283 "aws_elasticache_replication_group": resourceAwsElasticacheReplicationGroup(), 284 "aws_elasticache_security_group": resourceAwsElasticacheSecurityGroup(), 285 "aws_elasticache_subnet_group": resourceAwsElasticacheSubnetGroup(), 286 "aws_elastic_beanstalk_application": resourceAwsElasticBeanstalkApplication(), 287 "aws_elastic_beanstalk_application_version": resourceAwsElasticBeanstalkApplicationVersion(), 288 "aws_elastic_beanstalk_configuration_template": resourceAwsElasticBeanstalkConfigurationTemplate(), 289 "aws_elastic_beanstalk_environment": resourceAwsElasticBeanstalkEnvironment(), 290 "aws_elasticsearch_domain": resourceAwsElasticSearchDomain(), 291 "aws_elasticsearch_domain_policy": resourceAwsElasticSearchDomainPolicy(), 292 "aws_elastictranscoder_pipeline": resourceAwsElasticTranscoderPipeline(), 293 "aws_elastictranscoder_preset": resourceAwsElasticTranscoderPreset(), 294 "aws_elb": resourceAwsElb(), 295 "aws_elb_attachment": resourceAwsElbAttachment(), 296 "aws_emr_cluster": resourceAwsEMRCluster(), 297 "aws_emr_instance_group": resourceAwsEMRInstanceGroup(), 298 "aws_flow_log": resourceAwsFlowLog(), 299 "aws_glacier_vault": resourceAwsGlacierVault(), 300 "aws_iam_access_key": resourceAwsIamAccessKey(), 301 "aws_iam_account_password_policy": resourceAwsIamAccountPasswordPolicy(), 302 "aws_iam_group_policy": resourceAwsIamGroupPolicy(), 303 "aws_iam_group": resourceAwsIamGroup(), 304 "aws_iam_group_membership": resourceAwsIamGroupMembership(), 305 "aws_iam_group_policy_attachment": resourceAwsIamGroupPolicyAttachment(), 306 "aws_iam_instance_profile": resourceAwsIamInstanceProfile(), 307 "aws_iam_policy": resourceAwsIamPolicy(), 308 "aws_iam_policy_attachment": resourceAwsIamPolicyAttachment(), 309 "aws_iam_role_policy_attachment": resourceAwsIamRolePolicyAttachment(), 310 "aws_iam_role_policy": resourceAwsIamRolePolicy(), 311 "aws_iam_role": resourceAwsIamRole(), 312 "aws_iam_saml_provider": resourceAwsIamSamlProvider(), 313 "aws_iam_server_certificate": resourceAwsIAMServerCertificate(), 314 "aws_iam_user_policy_attachment": resourceAwsIamUserPolicyAttachment(), 315 "aws_iam_user_policy": resourceAwsIamUserPolicy(), 316 "aws_iam_user_ssh_key": resourceAwsIamUserSshKey(), 317 "aws_iam_user": resourceAwsIamUser(), 318 "aws_iam_user_login_profile": resourceAwsIamUserLoginProfile(), 319 "aws_inspector_assessment_target": resourceAWSInspectorAssessmentTarget(), 320 "aws_inspector_assessment_template": resourceAWSInspectorAssessmentTemplate(), 321 "aws_inspector_resource_group": resourceAWSInspectorResourceGroup(), 322 "aws_instance": resourceAwsInstance(), 323 "aws_internet_gateway": resourceAwsInternetGateway(), 324 "aws_key_pair": resourceAwsKeyPair(), 325 "aws_kinesis_firehose_delivery_stream": resourceAwsKinesisFirehoseDeliveryStream(), 326 "aws_kinesis_stream": resourceAwsKinesisStream(), 327 "aws_kms_alias": resourceAwsKmsAlias(), 328 "aws_kms_key": resourceAwsKmsKey(), 329 "aws_lambda_function": resourceAwsLambdaFunction(), 330 "aws_lambda_event_source_mapping": resourceAwsLambdaEventSourceMapping(), 331 "aws_lambda_alias": resourceAwsLambdaAlias(), 332 "aws_lambda_permission": resourceAwsLambdaPermission(), 333 "aws_launch_configuration": resourceAwsLaunchConfiguration(), 334 "aws_lightsail_domain": resourceAwsLightsailDomain(), 335 "aws_lightsail_instance": resourceAwsLightsailInstance(), 336 "aws_lightsail_key_pair": resourceAwsLightsailKeyPair(), 337 "aws_lb_cookie_stickiness_policy": resourceAwsLBCookieStickinessPolicy(), 338 "aws_load_balancer_policy": resourceAwsLoadBalancerPolicy(), 339 "aws_load_balancer_backend_server_policy": resourceAwsLoadBalancerBackendServerPolicies(), 340 "aws_load_balancer_listener_policy": resourceAwsLoadBalancerListenerPolicies(), 341 "aws_lb_ssl_negotiation_policy": resourceAwsLBSSLNegotiationPolicy(), 342 "aws_main_route_table_association": resourceAwsMainRouteTableAssociation(), 343 "aws_nat_gateway": resourceAwsNatGateway(), 344 "aws_network_acl": resourceAwsNetworkAcl(), 345 "aws_default_network_acl": resourceAwsDefaultNetworkAcl(), 346 "aws_default_route_table": resourceAwsDefaultRouteTable(), 347 "aws_network_acl_rule": resourceAwsNetworkAclRule(), 348 "aws_network_interface": resourceAwsNetworkInterface(), 349 "aws_opsworks_application": resourceAwsOpsworksApplication(), 350 "aws_opsworks_stack": resourceAwsOpsworksStack(), 351 "aws_opsworks_java_app_layer": resourceAwsOpsworksJavaAppLayer(), 352 "aws_opsworks_haproxy_layer": resourceAwsOpsworksHaproxyLayer(), 353 "aws_opsworks_static_web_layer": resourceAwsOpsworksStaticWebLayer(), 354 "aws_opsworks_php_app_layer": resourceAwsOpsworksPhpAppLayer(), 355 "aws_opsworks_rails_app_layer": resourceAwsOpsworksRailsAppLayer(), 356 "aws_opsworks_nodejs_app_layer": resourceAwsOpsworksNodejsAppLayer(), 357 "aws_opsworks_memcached_layer": resourceAwsOpsworksMemcachedLayer(), 358 "aws_opsworks_mysql_layer": resourceAwsOpsworksMysqlLayer(), 359 "aws_opsworks_ganglia_layer": resourceAwsOpsworksGangliaLayer(), 360 "aws_opsworks_custom_layer": resourceAwsOpsworksCustomLayer(), 361 "aws_opsworks_instance": resourceAwsOpsworksInstance(), 362 "aws_opsworks_user_profile": resourceAwsOpsworksUserProfile(), 363 "aws_opsworks_permission": resourceAwsOpsworksPermission(), 364 "aws_opsworks_rds_db_instance": resourceAwsOpsworksRdsDbInstance(), 365 "aws_placement_group": resourceAwsPlacementGroup(), 366 "aws_proxy_protocol_policy": resourceAwsProxyProtocolPolicy(), 367 "aws_rds_cluster": resourceAwsRDSCluster(), 368 "aws_rds_cluster_instance": resourceAwsRDSClusterInstance(), 369 "aws_rds_cluster_parameter_group": resourceAwsRDSClusterParameterGroup(), 370 "aws_redshift_cluster": resourceAwsRedshiftCluster(), 371 "aws_redshift_security_group": resourceAwsRedshiftSecurityGroup(), 372 "aws_redshift_parameter_group": resourceAwsRedshiftParameterGroup(), 373 "aws_redshift_subnet_group": resourceAwsRedshiftSubnetGroup(), 374 "aws_route53_delegation_set": resourceAwsRoute53DelegationSet(), 375 "aws_route53_record": resourceAwsRoute53Record(), 376 "aws_route53_zone_association": resourceAwsRoute53ZoneAssociation(), 377 "aws_route53_zone": resourceAwsRoute53Zone(), 378 "aws_route53_health_check": resourceAwsRoute53HealthCheck(), 379 "aws_route": resourceAwsRoute(), 380 "aws_route_table": resourceAwsRouteTable(), 381 "aws_route_table_association": resourceAwsRouteTableAssociation(), 382 "aws_ses_active_receipt_rule_set": resourceAwsSesActiveReceiptRuleSet(), 383 "aws_ses_receipt_filter": resourceAwsSesReceiptFilter(), 384 "aws_ses_receipt_rule": resourceAwsSesReceiptRule(), 385 "aws_ses_receipt_rule_set": resourceAwsSesReceiptRuleSet(), 386 "aws_ses_configuration_set": resourceAwsSesConfigurationSet(), 387 "aws_ses_event_destination": resourceAwsSesEventDestination(), 388 "aws_s3_bucket": resourceAwsS3Bucket(), 389 "aws_s3_bucket_policy": resourceAwsS3BucketPolicy(), 390 "aws_s3_bucket_object": resourceAwsS3BucketObject(), 391 "aws_s3_bucket_notification": resourceAwsS3BucketNotification(), 392 "aws_default_security_group": resourceAwsDefaultSecurityGroup(), 393 "aws_security_group": resourceAwsSecurityGroup(), 394 "aws_security_group_rule": resourceAwsSecurityGroupRule(), 395 "aws_simpledb_domain": resourceAwsSimpleDBDomain(), 396 "aws_ssm_activation": resourceAwsSsmActivation(), 397 "aws_ssm_association": resourceAwsSsmAssociation(), 398 "aws_ssm_document": resourceAwsSsmDocument(), 399 "aws_spot_datafeed_subscription": resourceAwsSpotDataFeedSubscription(), 400 "aws_spot_instance_request": resourceAwsSpotInstanceRequest(), 401 "aws_spot_fleet_request": resourceAwsSpotFleetRequest(), 402 "aws_sqs_queue": resourceAwsSqsQueue(), 403 "aws_sqs_queue_policy": resourceAwsSqsQueuePolicy(), 404 "aws_snapshot_create_volume_permission": resourceAwsSnapshotCreateVolumePermission(), 405 "aws_sns_topic": resourceAwsSnsTopic(), 406 "aws_sns_topic_policy": resourceAwsSnsTopicPolicy(), 407 "aws_sns_topic_subscription": resourceAwsSnsTopicSubscription(), 408 "aws_sfn_activity": resourceAwsSfnActivity(), 409 "aws_sfn_state_machine": resourceAwsSfnStateMachine(), 410 "aws_subnet": resourceAwsSubnet(), 411 "aws_volume_attachment": resourceAwsVolumeAttachment(), 412 "aws_vpc_dhcp_options_association": resourceAwsVpcDhcpOptionsAssociation(), 413 "aws_vpc_dhcp_options": resourceAwsVpcDhcpOptions(), 414 "aws_vpc_peering_connection": resourceAwsVpcPeeringConnection(), 415 "aws_vpc_peering_connection_accepter": resourceAwsVpcPeeringConnectionAccepter(), 416 "aws_vpc": resourceAwsVpc(), 417 "aws_vpc_endpoint": resourceAwsVpcEndpoint(), 418 "aws_vpc_endpoint_route_table_association": resourceAwsVpcEndpointRouteTableAssociation(), 419 "aws_vpn_connection": resourceAwsVpnConnection(), 420 "aws_vpn_connection_route": resourceAwsVpnConnectionRoute(), 421 "aws_vpn_gateway": resourceAwsVpnGateway(), 422 "aws_vpn_gateway_attachment": resourceAwsVpnGatewayAttachment(), 423 "aws_waf_byte_match_set": resourceAwsWafByteMatchSet(), 424 "aws_waf_ipset": resourceAwsWafIPSet(), 425 "aws_waf_rule": resourceAwsWafRule(), 426 "aws_waf_size_constraint_set": resourceAwsWafSizeConstraintSet(), 427 "aws_waf_web_acl": resourceAwsWafWebAcl(), 428 "aws_waf_xss_match_set": resourceAwsWafXssMatchSet(), 429 "aws_waf_sql_injection_match_set": resourceAwsWafSqlInjectionMatchSet(), 430 }, 431 ConfigureFunc: providerConfigure, 432 } 433 } 434 435 var descriptions map[string]string 436 437 func init() { 438 descriptions = map[string]string{ 439 "region": "The region where AWS operations will take place. Examples\n" + 440 "are us-east-1, us-west-2, etc.", 441 442 "access_key": "The access key for API operations. You can retrieve this\n" + 443 "from the 'Security & Credentials' section of the AWS console.", 444 445 "secret_key": "The secret key for API operations. You can retrieve this\n" + 446 "from the 'Security & Credentials' section of the AWS console.", 447 448 "profile": "The profile for API operations. If not set, the default profile\n" + 449 "created with `aws configure` will be used.", 450 451 "shared_credentials_file": "The path to the shared credentials file. If not set\n" + 452 "this defaults to ~/.aws/credentials.", 453 454 "token": "session token. A session token is only required if you are\n" + 455 "using temporary security credentials.", 456 457 "max_retries": "The maximum number of times an AWS API request is\n" + 458 "being executed. If the API request still fails, an error is\n" + 459 "thrown.", 460 461 "dynamodb_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n" + 462 "It's typically used to connect to dynamodb-local.", 463 464 "kinesis_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n" + 465 "It's typically used to connect to kinesalite.", 466 467 "iam_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", 468 469 "ec2_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", 470 471 "elb_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", 472 473 "s3_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", 474 475 "insecure": "Explicitly allow the provider to perform \"insecure\" SSL requests. If omitted," + 476 "default value is `false`", 477 478 "skip_credentials_validation": "Skip the credentials validation via STS API. " + 479 "Used for AWS API implementations that do not have STS available/implemented.", 480 481 "skip_region_validation": "Skip static validation of region name. " + 482 "Used by users of alternative AWS-like APIs or users w/ access to regions that are not public (yet).", 483 484 "skip_requesting_account_id": "Skip requesting the account ID. " + 485 "Used for AWS API implementations that do not have IAM/STS API and/or metadata API.", 486 487 "skip_medatadata_api_check": "Skip the AWS Metadata API check. " + 488 "Used for AWS API implementations that do not have a metadata api endpoint.", 489 490 "s3_force_path_style": "Set this to true to force the request to use path-style addressing,\n" + 491 "i.e., http://s3.amazonaws.com/BUCKET/KEY. By default, the S3 client will\n" + 492 "use virtual hosted bucket addressing when possible\n" + 493 "(http://BUCKET.s3.amazonaws.com/KEY). Specific to the Amazon S3 service.", 494 495 "assume_role_role_arn": "The ARN of an IAM role to assume prior to making API calls.", 496 497 "assume_role_session_name": "The session name to use when assuming the role. If omitted," + 498 " no session name is passed to the AssumeRole call.", 499 500 "assume_role_external_id": "The external ID to use when assuming the role. If omitted," + 501 " no external ID is passed to the AssumeRole call.", 502 503 "assume_role_policy": "The permissions applied when assuming a role. You cannot use," + 504 " this policy to grant further permissions that are in excess to those of the, " + 505 " role that is being assumed.", 506 } 507 } 508 509 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 510 config := Config{ 511 AccessKey: d.Get("access_key").(string), 512 SecretKey: d.Get("secret_key").(string), 513 Profile: d.Get("profile").(string), 514 CredsFilename: d.Get("shared_credentials_file").(string), 515 Token: d.Get("token").(string), 516 Region: d.Get("region").(string), 517 MaxRetries: d.Get("max_retries").(int), 518 Insecure: d.Get("insecure").(bool), 519 SkipCredsValidation: d.Get("skip_credentials_validation").(bool), 520 SkipRegionValidation: d.Get("skip_region_validation").(bool), 521 SkipRequestingAccountId: d.Get("skip_requesting_account_id").(bool), 522 SkipMetadataApiCheck: d.Get("skip_metadata_api_check").(bool), 523 S3ForcePathStyle: d.Get("s3_force_path_style").(bool), 524 } 525 526 assumeRoleList := d.Get("assume_role").(*schema.Set).List() 527 if len(assumeRoleList) == 1 { 528 assumeRole := assumeRoleList[0].(map[string]interface{}) 529 config.AssumeRoleARN = assumeRole["role_arn"].(string) 530 config.AssumeRoleSessionName = assumeRole["session_name"].(string) 531 config.AssumeRoleExternalID = assumeRole["external_id"].(string) 532 533 if v := assumeRole["policy"].(string); v != "" { 534 config.AssumeRolePolicy = v 535 } 536 537 log.Printf("[INFO] assume_role configuration set: (ARN: %q, SessionID: %q, ExternalID: %q, Policy: %q)", 538 config.AssumeRoleARN, config.AssumeRoleSessionName, config.AssumeRoleExternalID, config.AssumeRolePolicy) 539 } else { 540 log.Printf("[INFO] No assume_role block read from configuration") 541 } 542 543 endpointsSet := d.Get("endpoints").(*schema.Set) 544 545 for _, endpointsSetI := range endpointsSet.List() { 546 endpoints := endpointsSetI.(map[string]interface{}) 547 config.DynamoDBEndpoint = endpoints["dynamodb"].(string) 548 config.IamEndpoint = endpoints["iam"].(string) 549 config.Ec2Endpoint = endpoints["ec2"].(string) 550 config.ElbEndpoint = endpoints["elb"].(string) 551 config.KinesisEndpoint = endpoints["kinesis"].(string) 552 config.S3Endpoint = endpoints["s3"].(string) 553 } 554 555 if v, ok := d.GetOk("allowed_account_ids"); ok { 556 config.AllowedAccountIds = v.(*schema.Set).List() 557 } 558 559 if v, ok := d.GetOk("forbidden_account_ids"); ok { 560 config.ForbiddenAccountIds = v.(*schema.Set).List() 561 } 562 563 return config.Client() 564 } 565 566 // This is a global MutexKV for use within this plugin. 567 var awsMutexKV = mutexkv.NewMutexKV() 568 569 func assumeRoleSchema() *schema.Schema { 570 return &schema.Schema{ 571 Type: schema.TypeSet, 572 Optional: true, 573 MaxItems: 1, 574 Elem: &schema.Resource{ 575 Schema: map[string]*schema.Schema{ 576 "role_arn": { 577 Type: schema.TypeString, 578 Optional: true, 579 Description: descriptions["assume_role_role_arn"], 580 }, 581 582 "session_name": { 583 Type: schema.TypeString, 584 Optional: true, 585 Description: descriptions["assume_role_session_name"], 586 }, 587 588 "external_id": { 589 Type: schema.TypeString, 590 Optional: true, 591 Description: descriptions["assume_role_external_id"], 592 }, 593 594 "policy": { 595 Type: schema.TypeString, 596 Optional: true, 597 Description: descriptions["assume_role_policy"], 598 }, 599 }, 600 }, 601 Set: assumeRoleToHash, 602 } 603 } 604 605 func assumeRoleToHash(v interface{}) int { 606 var buf bytes.Buffer 607 m := v.(map[string]interface{}) 608 buf.WriteString(fmt.Sprintf("%s-", m["role_arn"].(string))) 609 buf.WriteString(fmt.Sprintf("%s-", m["session_name"].(string))) 610 buf.WriteString(fmt.Sprintf("%s-", m["external_id"].(string))) 611 buf.WriteString(fmt.Sprintf("%s-", m["policy"].(string))) 612 return hashcode.String(buf.String()) 613 } 614 615 func endpointsSchema() *schema.Schema { 616 return &schema.Schema{ 617 Type: schema.TypeSet, 618 Optional: true, 619 Elem: &schema.Resource{ 620 Schema: map[string]*schema.Schema{ 621 "dynamodb": { 622 Type: schema.TypeString, 623 Optional: true, 624 Default: "", 625 Description: descriptions["dynamodb_endpoint"], 626 }, 627 "iam": { 628 Type: schema.TypeString, 629 Optional: true, 630 Default: "", 631 Description: descriptions["iam_endpoint"], 632 }, 633 634 "ec2": { 635 Type: schema.TypeString, 636 Optional: true, 637 Default: "", 638 Description: descriptions["ec2_endpoint"], 639 }, 640 641 "elb": { 642 Type: schema.TypeString, 643 Optional: true, 644 Default: "", 645 Description: descriptions["elb_endpoint"], 646 }, 647 "kinesis": { 648 Type: schema.TypeString, 649 Optional: true, 650 Default: "", 651 Description: descriptions["kinesis_endpoint"], 652 }, 653 "s3": { 654 Type: schema.TypeString, 655 Optional: true, 656 Default: "", 657 Description: descriptions["s3_endpoint"], 658 }, 659 }, 660 }, 661 Set: endpointsToHash, 662 } 663 } 664 665 func endpointsToHash(v interface{}) int { 666 var buf bytes.Buffer 667 m := v.(map[string]interface{}) 668 buf.WriteString(fmt.Sprintf("%s-", m["dynamodb"].(string))) 669 buf.WriteString(fmt.Sprintf("%s-", m["iam"].(string))) 670 buf.WriteString(fmt.Sprintf("%s-", m["ec2"].(string))) 671 buf.WriteString(fmt.Sprintf("%s-", m["elb"].(string))) 672 buf.WriteString(fmt.Sprintf("%s-", m["kinesis"].(string))) 673 buf.WriteString(fmt.Sprintf("%s-", m["s3"].(string))) 674 675 return hashcode.String(buf.String()) 676 }