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