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