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