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