github.com/peterbale/terraform@v0.9.0-beta2.0.20170315142748-5723acd55547/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_alias": resourceAwsIamAccountAlias(), 302 "aws_iam_account_password_policy": resourceAwsIamAccountPasswordPolicy(), 303 "aws_iam_group_policy": resourceAwsIamGroupPolicy(), 304 "aws_iam_group": resourceAwsIamGroup(), 305 "aws_iam_group_membership": resourceAwsIamGroupMembership(), 306 "aws_iam_group_policy_attachment": resourceAwsIamGroupPolicyAttachment(), 307 "aws_iam_instance_profile": resourceAwsIamInstanceProfile(), 308 "aws_iam_policy": resourceAwsIamPolicy(), 309 "aws_iam_policy_attachment": resourceAwsIamPolicyAttachment(), 310 "aws_iam_role_policy_attachment": resourceAwsIamRolePolicyAttachment(), 311 "aws_iam_role_policy": resourceAwsIamRolePolicy(), 312 "aws_iam_role": resourceAwsIamRole(), 313 "aws_iam_saml_provider": resourceAwsIamSamlProvider(), 314 "aws_iam_server_certificate": resourceAwsIAMServerCertificate(), 315 "aws_iam_user_policy_attachment": resourceAwsIamUserPolicyAttachment(), 316 "aws_iam_user_policy": resourceAwsIamUserPolicy(), 317 "aws_iam_user_ssh_key": resourceAwsIamUserSshKey(), 318 "aws_iam_user": resourceAwsIamUser(), 319 "aws_iam_user_login_profile": resourceAwsIamUserLoginProfile(), 320 "aws_inspector_assessment_target": resourceAWSInspectorAssessmentTarget(), 321 "aws_inspector_assessment_template": resourceAWSInspectorAssessmentTemplate(), 322 "aws_inspector_resource_group": resourceAWSInspectorResourceGroup(), 323 "aws_instance": resourceAwsInstance(), 324 "aws_internet_gateway": resourceAwsInternetGateway(), 325 "aws_key_pair": resourceAwsKeyPair(), 326 "aws_kinesis_firehose_delivery_stream": resourceAwsKinesisFirehoseDeliveryStream(), 327 "aws_kinesis_stream": resourceAwsKinesisStream(), 328 "aws_kms_alias": resourceAwsKmsAlias(), 329 "aws_kms_key": resourceAwsKmsKey(), 330 "aws_lambda_function": resourceAwsLambdaFunction(), 331 "aws_lambda_event_source_mapping": resourceAwsLambdaEventSourceMapping(), 332 "aws_lambda_alias": resourceAwsLambdaAlias(), 333 "aws_lambda_permission": resourceAwsLambdaPermission(), 334 "aws_launch_configuration": resourceAwsLaunchConfiguration(), 335 "aws_lightsail_domain": resourceAwsLightsailDomain(), 336 "aws_lightsail_instance": resourceAwsLightsailInstance(), 337 "aws_lightsail_key_pair": resourceAwsLightsailKeyPair(), 338 "aws_lb_cookie_stickiness_policy": resourceAwsLBCookieStickinessPolicy(), 339 "aws_load_balancer_policy": resourceAwsLoadBalancerPolicy(), 340 "aws_load_balancer_backend_server_policy": resourceAwsLoadBalancerBackendServerPolicies(), 341 "aws_load_balancer_listener_policy": resourceAwsLoadBalancerListenerPolicies(), 342 "aws_lb_ssl_negotiation_policy": resourceAwsLBSSLNegotiationPolicy(), 343 "aws_main_route_table_association": resourceAwsMainRouteTableAssociation(), 344 "aws_nat_gateway": resourceAwsNatGateway(), 345 "aws_network_acl": resourceAwsNetworkAcl(), 346 "aws_default_network_acl": resourceAwsDefaultNetworkAcl(), 347 "aws_default_route_table": resourceAwsDefaultRouteTable(), 348 "aws_network_acl_rule": resourceAwsNetworkAclRule(), 349 "aws_network_interface": resourceAwsNetworkInterface(), 350 "aws_opsworks_application": resourceAwsOpsworksApplication(), 351 "aws_opsworks_stack": resourceAwsOpsworksStack(), 352 "aws_opsworks_java_app_layer": resourceAwsOpsworksJavaAppLayer(), 353 "aws_opsworks_haproxy_layer": resourceAwsOpsworksHaproxyLayer(), 354 "aws_opsworks_static_web_layer": resourceAwsOpsworksStaticWebLayer(), 355 "aws_opsworks_php_app_layer": resourceAwsOpsworksPhpAppLayer(), 356 "aws_opsworks_rails_app_layer": resourceAwsOpsworksRailsAppLayer(), 357 "aws_opsworks_nodejs_app_layer": resourceAwsOpsworksNodejsAppLayer(), 358 "aws_opsworks_memcached_layer": resourceAwsOpsworksMemcachedLayer(), 359 "aws_opsworks_mysql_layer": resourceAwsOpsworksMysqlLayer(), 360 "aws_opsworks_ganglia_layer": resourceAwsOpsworksGangliaLayer(), 361 "aws_opsworks_custom_layer": resourceAwsOpsworksCustomLayer(), 362 "aws_opsworks_instance": resourceAwsOpsworksInstance(), 363 "aws_opsworks_user_profile": resourceAwsOpsworksUserProfile(), 364 "aws_opsworks_permission": resourceAwsOpsworksPermission(), 365 "aws_opsworks_rds_db_instance": resourceAwsOpsworksRdsDbInstance(), 366 "aws_placement_group": resourceAwsPlacementGroup(), 367 "aws_proxy_protocol_policy": resourceAwsProxyProtocolPolicy(), 368 "aws_rds_cluster": resourceAwsRDSCluster(), 369 "aws_rds_cluster_instance": resourceAwsRDSClusterInstance(), 370 "aws_rds_cluster_parameter_group": resourceAwsRDSClusterParameterGroup(), 371 "aws_redshift_cluster": resourceAwsRedshiftCluster(), 372 "aws_redshift_security_group": resourceAwsRedshiftSecurityGroup(), 373 "aws_redshift_parameter_group": resourceAwsRedshiftParameterGroup(), 374 "aws_redshift_subnet_group": resourceAwsRedshiftSubnetGroup(), 375 "aws_route53_delegation_set": resourceAwsRoute53DelegationSet(), 376 "aws_route53_record": resourceAwsRoute53Record(), 377 "aws_route53_zone_association": resourceAwsRoute53ZoneAssociation(), 378 "aws_route53_zone": resourceAwsRoute53Zone(), 379 "aws_route53_health_check": resourceAwsRoute53HealthCheck(), 380 "aws_route": resourceAwsRoute(), 381 "aws_route_table": resourceAwsRouteTable(), 382 "aws_route_table_association": resourceAwsRouteTableAssociation(), 383 "aws_ses_active_receipt_rule_set": resourceAwsSesActiveReceiptRuleSet(), 384 "aws_ses_receipt_filter": resourceAwsSesReceiptFilter(), 385 "aws_ses_receipt_rule": resourceAwsSesReceiptRule(), 386 "aws_ses_receipt_rule_set": resourceAwsSesReceiptRuleSet(), 387 "aws_ses_configuration_set": resourceAwsSesConfigurationSet(), 388 "aws_ses_event_destination": resourceAwsSesEventDestination(), 389 "aws_s3_bucket": resourceAwsS3Bucket(), 390 "aws_s3_bucket_policy": resourceAwsS3BucketPolicy(), 391 "aws_s3_bucket_object": resourceAwsS3BucketObject(), 392 "aws_s3_bucket_notification": resourceAwsS3BucketNotification(), 393 "aws_default_security_group": resourceAwsDefaultSecurityGroup(), 394 "aws_security_group": resourceAwsSecurityGroup(), 395 "aws_security_group_rule": resourceAwsSecurityGroupRule(), 396 "aws_simpledb_domain": resourceAwsSimpleDBDomain(), 397 "aws_ssm_activation": resourceAwsSsmActivation(), 398 "aws_ssm_association": resourceAwsSsmAssociation(), 399 "aws_ssm_document": resourceAwsSsmDocument(), 400 "aws_spot_datafeed_subscription": resourceAwsSpotDataFeedSubscription(), 401 "aws_spot_instance_request": resourceAwsSpotInstanceRequest(), 402 "aws_spot_fleet_request": resourceAwsSpotFleetRequest(), 403 "aws_sqs_queue": resourceAwsSqsQueue(), 404 "aws_sqs_queue_policy": resourceAwsSqsQueuePolicy(), 405 "aws_snapshot_create_volume_permission": resourceAwsSnapshotCreateVolumePermission(), 406 "aws_sns_topic": resourceAwsSnsTopic(), 407 "aws_sns_topic_policy": resourceAwsSnsTopicPolicy(), 408 "aws_sns_topic_subscription": resourceAwsSnsTopicSubscription(), 409 "aws_sfn_activity": resourceAwsSfnActivity(), 410 "aws_sfn_state_machine": resourceAwsSfnStateMachine(), 411 "aws_subnet": resourceAwsSubnet(), 412 "aws_volume_attachment": resourceAwsVolumeAttachment(), 413 "aws_vpc_dhcp_options_association": resourceAwsVpcDhcpOptionsAssociation(), 414 "aws_vpc_dhcp_options": resourceAwsVpcDhcpOptions(), 415 "aws_vpc_peering_connection": resourceAwsVpcPeeringConnection(), 416 "aws_vpc_peering_connection_accepter": resourceAwsVpcPeeringConnectionAccepter(), 417 "aws_vpc": resourceAwsVpc(), 418 "aws_vpc_endpoint": resourceAwsVpcEndpoint(), 419 "aws_vpc_endpoint_route_table_association": resourceAwsVpcEndpointRouteTableAssociation(), 420 "aws_vpn_connection": resourceAwsVpnConnection(), 421 "aws_vpn_connection_route": resourceAwsVpnConnectionRoute(), 422 "aws_vpn_gateway": resourceAwsVpnGateway(), 423 "aws_vpn_gateway_attachment": resourceAwsVpnGatewayAttachment(), 424 "aws_waf_byte_match_set": resourceAwsWafByteMatchSet(), 425 "aws_waf_ipset": resourceAwsWafIPSet(), 426 "aws_waf_rule": resourceAwsWafRule(), 427 "aws_waf_size_constraint_set": resourceAwsWafSizeConstraintSet(), 428 "aws_waf_web_acl": resourceAwsWafWebAcl(), 429 "aws_waf_xss_match_set": resourceAwsWafXssMatchSet(), 430 "aws_waf_sql_injection_match_set": resourceAwsWafSqlInjectionMatchSet(), 431 }, 432 ConfigureFunc: providerConfigure, 433 } 434 } 435 436 var descriptions map[string]string 437 438 func init() { 439 descriptions = map[string]string{ 440 "region": "The region where AWS operations will take place. Examples\n" + 441 "are us-east-1, us-west-2, etc.", 442 443 "access_key": "The access key for API operations. You can retrieve this\n" + 444 "from the 'Security & Credentials' section of the AWS console.", 445 446 "secret_key": "The secret key for API operations. You can retrieve this\n" + 447 "from the 'Security & Credentials' section of the AWS console.", 448 449 "profile": "The profile for API operations. If not set, the default profile\n" + 450 "created with `aws configure` will be used.", 451 452 "shared_credentials_file": "The path to the shared credentials file. If not set\n" + 453 "this defaults to ~/.aws/credentials.", 454 455 "token": "session token. A session token is only required if you are\n" + 456 "using temporary security credentials.", 457 458 "max_retries": "The maximum number of times an AWS API request is\n" + 459 "being executed. If the API request still fails, an error is\n" + 460 "thrown.", 461 462 "dynamodb_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n" + 463 "It's typically used to connect to dynamodb-local.", 464 465 "kinesis_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n" + 466 "It's typically used to connect to kinesalite.", 467 468 "iam_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", 469 470 "ec2_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", 471 472 "elb_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", 473 474 "s3_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", 475 476 "insecure": "Explicitly allow the provider to perform \"insecure\" SSL requests. If omitted," + 477 "default value is `false`", 478 479 "skip_credentials_validation": "Skip the credentials validation via STS API. " + 480 "Used for AWS API implementations that do not have STS available/implemented.", 481 482 "skip_region_validation": "Skip static validation of region name. " + 483 "Used by users of alternative AWS-like APIs or users w/ access to regions that are not public (yet).", 484 485 "skip_requesting_account_id": "Skip requesting the account ID. " + 486 "Used for AWS API implementations that do not have IAM/STS API and/or metadata API.", 487 488 "skip_medatadata_api_check": "Skip the AWS Metadata API check. " + 489 "Used for AWS API implementations that do not have a metadata api endpoint.", 490 491 "s3_force_path_style": "Set this to true to force the request to use path-style addressing,\n" + 492 "i.e., http://s3.amazonaws.com/BUCKET/KEY. By default, the S3 client will\n" + 493 "use virtual hosted bucket addressing when possible\n" + 494 "(http://BUCKET.s3.amazonaws.com/KEY). Specific to the Amazon S3 service.", 495 496 "assume_role_role_arn": "The ARN of an IAM role to assume prior to making API calls.", 497 498 "assume_role_session_name": "The session name to use when assuming the role. If omitted," + 499 " no session name is passed to the AssumeRole call.", 500 501 "assume_role_external_id": "The external ID to use when assuming the role. If omitted," + 502 " no external ID is passed to the AssumeRole call.", 503 504 "assume_role_policy": "The permissions applied when assuming a role. You cannot use," + 505 " this policy to grant further permissions that are in excess to those of the, " + 506 " role that is being assumed.", 507 } 508 } 509 510 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 511 config := Config{ 512 AccessKey: d.Get("access_key").(string), 513 SecretKey: d.Get("secret_key").(string), 514 Profile: d.Get("profile").(string), 515 CredsFilename: d.Get("shared_credentials_file").(string), 516 Token: d.Get("token").(string), 517 Region: d.Get("region").(string), 518 MaxRetries: d.Get("max_retries").(int), 519 Insecure: d.Get("insecure").(bool), 520 SkipCredsValidation: d.Get("skip_credentials_validation").(bool), 521 SkipRegionValidation: d.Get("skip_region_validation").(bool), 522 SkipRequestingAccountId: d.Get("skip_requesting_account_id").(bool), 523 SkipMetadataApiCheck: d.Get("skip_metadata_api_check").(bool), 524 S3ForcePathStyle: d.Get("s3_force_path_style").(bool), 525 } 526 527 assumeRoleList := d.Get("assume_role").(*schema.Set).List() 528 if len(assumeRoleList) == 1 { 529 assumeRole := assumeRoleList[0].(map[string]interface{}) 530 config.AssumeRoleARN = assumeRole["role_arn"].(string) 531 config.AssumeRoleSessionName = assumeRole["session_name"].(string) 532 config.AssumeRoleExternalID = assumeRole["external_id"].(string) 533 534 if v := assumeRole["policy"].(string); v != "" { 535 config.AssumeRolePolicy = v 536 } 537 538 log.Printf("[INFO] assume_role configuration set: (ARN: %q, SessionID: %q, ExternalID: %q, Policy: %q)", 539 config.AssumeRoleARN, config.AssumeRoleSessionName, config.AssumeRoleExternalID, config.AssumeRolePolicy) 540 } else { 541 log.Printf("[INFO] No assume_role block read from configuration") 542 } 543 544 endpointsSet := d.Get("endpoints").(*schema.Set) 545 546 for _, endpointsSetI := range endpointsSet.List() { 547 endpoints := endpointsSetI.(map[string]interface{}) 548 config.DynamoDBEndpoint = endpoints["dynamodb"].(string) 549 config.IamEndpoint = endpoints["iam"].(string) 550 config.Ec2Endpoint = endpoints["ec2"].(string) 551 config.ElbEndpoint = endpoints["elb"].(string) 552 config.KinesisEndpoint = endpoints["kinesis"].(string) 553 config.S3Endpoint = endpoints["s3"].(string) 554 } 555 556 if v, ok := d.GetOk("allowed_account_ids"); ok { 557 config.AllowedAccountIds = v.(*schema.Set).List() 558 } 559 560 if v, ok := d.GetOk("forbidden_account_ids"); ok { 561 config.ForbiddenAccountIds = v.(*schema.Set).List() 562 } 563 564 return config.Client() 565 } 566 567 // This is a global MutexKV for use within this plugin. 568 var awsMutexKV = mutexkv.NewMutexKV() 569 570 func assumeRoleSchema() *schema.Schema { 571 return &schema.Schema{ 572 Type: schema.TypeSet, 573 Optional: true, 574 MaxItems: 1, 575 Elem: &schema.Resource{ 576 Schema: map[string]*schema.Schema{ 577 "role_arn": { 578 Type: schema.TypeString, 579 Optional: true, 580 Description: descriptions["assume_role_role_arn"], 581 }, 582 583 "session_name": { 584 Type: schema.TypeString, 585 Optional: true, 586 Description: descriptions["assume_role_session_name"], 587 }, 588 589 "external_id": { 590 Type: schema.TypeString, 591 Optional: true, 592 Description: descriptions["assume_role_external_id"], 593 }, 594 595 "policy": { 596 Type: schema.TypeString, 597 Optional: true, 598 Description: descriptions["assume_role_policy"], 599 }, 600 }, 601 }, 602 Set: assumeRoleToHash, 603 } 604 } 605 606 func assumeRoleToHash(v interface{}) int { 607 var buf bytes.Buffer 608 m := v.(map[string]interface{}) 609 buf.WriteString(fmt.Sprintf("%s-", m["role_arn"].(string))) 610 buf.WriteString(fmt.Sprintf("%s-", m["session_name"].(string))) 611 buf.WriteString(fmt.Sprintf("%s-", m["external_id"].(string))) 612 buf.WriteString(fmt.Sprintf("%s-", m["policy"].(string))) 613 return hashcode.String(buf.String()) 614 } 615 616 func endpointsSchema() *schema.Schema { 617 return &schema.Schema{ 618 Type: schema.TypeSet, 619 Optional: true, 620 Elem: &schema.Resource{ 621 Schema: map[string]*schema.Schema{ 622 "dynamodb": { 623 Type: schema.TypeString, 624 Optional: true, 625 Default: "", 626 Description: descriptions["dynamodb_endpoint"], 627 }, 628 "iam": { 629 Type: schema.TypeString, 630 Optional: true, 631 Default: "", 632 Description: descriptions["iam_endpoint"], 633 }, 634 635 "ec2": { 636 Type: schema.TypeString, 637 Optional: true, 638 Default: "", 639 Description: descriptions["ec2_endpoint"], 640 }, 641 642 "elb": { 643 Type: schema.TypeString, 644 Optional: true, 645 Default: "", 646 Description: descriptions["elb_endpoint"], 647 }, 648 "kinesis": { 649 Type: schema.TypeString, 650 Optional: true, 651 Default: "", 652 Description: descriptions["kinesis_endpoint"], 653 }, 654 "s3": { 655 Type: schema.TypeString, 656 Optional: true, 657 Default: "", 658 Description: descriptions["s3_endpoint"], 659 }, 660 }, 661 }, 662 Set: endpointsToHash, 663 } 664 } 665 666 func endpointsToHash(v interface{}) int { 667 var buf bytes.Buffer 668 m := v.(map[string]interface{}) 669 buf.WriteString(fmt.Sprintf("%s-", m["dynamodb"].(string))) 670 buf.WriteString(fmt.Sprintf("%s-", m["iam"].(string))) 671 buf.WriteString(fmt.Sprintf("%s-", m["ec2"].(string))) 672 buf.WriteString(fmt.Sprintf("%s-", m["elb"].(string))) 673 buf.WriteString(fmt.Sprintf("%s-", m["kinesis"].(string))) 674 buf.WriteString(fmt.Sprintf("%s-", m["s3"].(string))) 675 676 return hashcode.String(buf.String()) 677 }