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