When you enable access logs for your load balancer, you must specify the name of the S3 bucket where the load balancer will store the logs. The bucket must have a bucket policy that grants Elastic Load Balancing permission to write to the bucket.
Step 1: Create an S3 bucketWhen you enable access logs, you must specify an S3 bucket for the access logs. You can use an existing bucket, or create a bucket specifically for access logs. The bucket must meet the following requirements.
RequirementsThe bucket must be located in the same Region as the load balancer. The bucket and the load balancer can be owned by different accounts.
The only server-side encryption option that's supported is Amazon S3-managed keys (SSE-S3). For more information, see Amazon S3-managed encryption keys (SSE-S3).
Open the Amazon S3 console at https://console.aws.amazon.com/s3/.
Choose Create bucket.
On the Create bucket page, do the following:
For Bucket name, enter a name for your bucket. This name must be unique across all existing bucket names in Amazon S3. In some Regions, there might be additional restrictions on bucket names. For more information, see Bucket restrictions and limitations in the Amazon S3 User Guide.
For AWS Region, select the Region where you created your load balancer.
For Default encryption, choose Amazon S3-managed keys (SSE-S3).
Choose Create bucket.
Your S3 bucket must have a bucket policy that grants Elastic Load Balancing permission to write the access logs to the bucket. Bucket policies are a collection of JSON statements written in the access policy language to define access permissions for your bucket. Each statement includes information about a single permission and contains a series of elements.
If you're using an existing bucket that already has an attached policy, you can add the statement for Elastic Load Balancing access logs to the policy. If you do so, we recommend that you evaluate the resulting set of permissions to ensure that they are appropriate for the users that need access to the bucket for access logs.
Available bucket policiesThe bucket policy that you'll use depends on the AWS Region and the type of zone. Each expandable section below contains a basic bucket policy and a description of the policy. To enhance security, see the suggestions below the collapsible sections.
This policy grants permissions to the specified log delivery service. Use this policy for load balancers in the following Regions:
Asia Pacific (Hyderabad)
Asia Pacific (Malaysia)
Asia Pacific (Melbourne)
Asia Pacific (Taipei)
Asia Pacific (Thailand)
Canada West (Calgary)
Europe (Spain)
Europe (Zurich)
Israel (Tel Aviv)
Middle East (UAE)
Mexico (Central)
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "logdelivery.elasticloadbalancing.amazonaws.com"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::amzn-s3-demo-bucket
/prefix
/AWSLogs/123456789012
/*"
}
]
}
For Resource
, enter the ARN of the location for the access logs, using the format shown in the example policy. Always include the account ID of the account with the load balancer in the resource path of the S3 bucket ARN. This ensures that only load balancers from the specified account can write access logs to the S3 bucket.
The ARN that you specify depends on whether you plan to include a prefix when you enable access logs in step 3.
Example S3 bucket ARN with a prefixThe S3 bucket name is amzn-s3-demo-logging-bucket and the prefix is logging-prefix.
arn:aws:s3:::amzn-s3-demo-logging-bucket/logging-prefix/AWSLogs/123456789012/*
Example S3 bucket ARN with no prefix
The S3 bucket name is amzn-s3-demo-logging-bucket. There is no prefix portion in the S3 bucket ARN.
arn:aws:s3:::amzn-s3-demo-logging-bucket/AWSLogs/123456789012/*
This policy grants permissions to the specified Elastic Load Balancing account ID. Use this policy for load balancers in the Regions listed below.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111122223333
:root"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::amzn-s3-demo-bucket
/prefix
/AWSLogs/123456789012
/*"
}
]
}
For Principal
, replace 111122223333
with the ID of the Elastic Load Balancing account for the Region of the load balancer:
US East (N. Virginia) â 127311923021
US East (Ohio) â 033677994240
US West (N. California) â 027434742980
US West (Oregon) â 797873946194
Africa (Cape Town) â 098369216593
Asia Pacific (Hong Kong) â 754344448648
Asia Pacific (Jakarta) â 589379963580
Asia Pacific (Mumbai) â 718504428378
Asia Pacific (Osaka) â 383597477331
Asia Pacific (Seoul) â 600734575887
Asia Pacific (Singapore) â 114774131450
Asia Pacific (Sydney) â 783225319266
Asia Pacific (Tokyo) â 582318560864
Canada (Central) â 985666609251
Europe (Frankfurt) â 054676820928
Europe (Ireland) â 156460612806
Europe (London) â 652711504416
Europe (Milan) â 635631232127
Europe (Paris) â 009996457667
Europe (Stockholm) â 897822967062
Middle East (Bahrain) â 076674570225
South America (São Paulo) â 507241528517
For Resource
, enter the ARN of the location for the access logs, using the format shown in the example policy. Always include the account ID of the account with the load balancer in the resource path of the S3 bucket ARN. This ensures that only load balancers from the specified account can write access logs to the S3 bucket.
The ARN that you specify depends on whether you plan to include a prefix when you enable access logs in step 3.
Example S3 bucket ARN with a prefixThe S3 bucket name is amzn-s3-demo-logging-bucket and the prefix is logging-prefix.
arn:aws:s3:::amzn-s3-demo-logging-bucket/logging-prefix/AWSLogs/123456789012/*
Example S3 bucket ARN with no prefix
The S3 bucket name is amzn-s3-demo-logging-bucket. There is no prefix portion in the S3 bucket ARN.
arn:aws:s3:::amzn-s3-demo-logging-bucket/AWSLogs/123456789012/*
This policy grants permissions to the specified Elastic Load Balancing account ID. Use this policy for load balancers in the AWS GovCloud (US) Regions.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws-us-gov:iam::111122223333
:root"
},
"Action": "s3:PutObject",
"Resource": "arn:aws-us-gov:s3:::amzn-s3-demo-bucket
/prefix
/AWSLogs/123456789012
/*"
}
]
}
For Principal
, replace 111122223333
with the ID of the Elastic Load Balancing account for the Region of the load balancer:
AWS GovCloud (US-West) â 048591011584
AWS GovCloud (US-East) â 190560391635
For Resource
, enter the ARN of the location for the access logs, using the format shown in the example policy. Always include the account ID of the account with the load balancer in the resource path of the S3 bucket ARN. This ensures that only load balancers from the specified account can write access logs to the S3 bucket.
The S3 bucket ARN that you specify depends on whether you plan to include a prefix when you enable access logs link step 3.
Example S3 bucket ARN with a prefixThe S3 bucket name is amzn-s3-demo-logging-bucket and the prefix is logging-prefix.
arn:aws-us-gov:s3:::amzn-s3-demo-logging-bucket/logging-prefix/AWSLogs/123456789012/*
Example S3 bucket ARN with no prefix
The S3 bucket name is amzn-s3-demo-logging-bucket. There is no prefix portion in the S3 bucket ARN.
arn:aws-us-gov:s3:::amzn-s3-demo-logging-bucket/AWSLogs/123456789012/*
The following policy grants permissions to the specified log delivery service. Use this policy for load balancers in Outposts Zones.
{
"Effect": "Allow",
"Principal": {
"Service": "logdelivery.elb.amazonaws.com"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::amzn-s3-demo-bucket
/prefix
/AWSLogs/123456789012
/*",
"Condition": {
"StringEquals": {
"s3:x-amz-acl": "bucket-owner-full-control"
}
}
}
For Resource
, enter the ARN of the location for the access logs, using the format shown in the example policy. Always include the account ID of the account with the load balancer in the resource path of the S3 bucket ARN. This ensures that only load balancers from the specified account can write access logs to the S3 bucket.
The S3 bucket ARN that you specify depends on whether you plan to include a prefix when you enable access logs in step 3.
Example S3 bucket ARN with a prefixThe S3 bucket name is amzn-s3-demo-logging-bucket and the prefix is logging-prefix.
arn:aws:s3:::amzn-s3-demo-logging-bucket/logging-prefix/AWSLogs/123456789012/*
Example S3 bucket ARN with no prefix
The S3 bucket name is amzn-s3-demo-logging-bucket. There is no prefix portion in the S3 bucket ARN.
arn:aws:s3:::amzn-s3-demo-logging-bucket/AWSLogs/123456789012/*
Enhance security
Use the following suggestions to enhance the security of your S3 bucket.
Review your bucket policyUse the full resource path, including the account ID portion of the S3 bucket ARN. Don't use wildcards (*) in the account ID portion of the S3 bucket ARN.
"Resource": "arn:aws:s3:::amzn-s3-demo-bucket
/prefix
/AWSLogs/123456789012
/*"
Use aws:SourceArn
to ensure that only load balancers from the specified Region and account can use your bucket.
"Condition": {
"ArnLike": {
"aws:SourceArn": "arn:aws:elasticloadbalancing:region
:123456789012
:loadbalancer/*"
}
}
Use aws:SourceOrgId
with aws:SourceArn
to ensure that only load balancers from the specified organization can use your bucket.
"Condition": {
"StringEquals": {
"aws:SourceOrgId": "o-1234567890
"
},
"ArnLike": {
"aws:SourceArn": "arn:aws:elasticloadbalancing:*:*:loadbalancer/*"
}
}
If you have a Deny
statement to prevent access to service principals except those explicitly allowed, be sure to add logdelivery.elasticloadbalancing.amazonaws.com
to the list of allowed service principals. For example, if you used the aws:PrincipalServiceNamesList
condition, add logdelivery.elasticloadbalancing.amazonaws.com
as follows:
{
"Effect": "Deny",
"Principal": "*",
"Condition": {
"StringNotEqualsIfExists": {
"aws:PrincipalServiceNamesList": [
"logdelivery.elasticloadbalancing.amazonaws.com",
"service
.amazonaws.com"
]
}
}
}
If you used the NotPrincipal
element, add logdelivery.elasticloadbalancing.amazonaws.com
as follows. Note that we recommend that you use the aws:PrincipalServiceName
or aws:PrincipalServiceNamesList
condition key to explicitly allow service principals instead of using the NotPrincipal
element. For more information, see NotPrincipal.
{
"Effect": "Deny",
"NotPrincipal": {
"Service": [
"logdelivery.elasticloadbalancing.amazonaws.com",
"service
.amazonaws.com"
]
}
},
Open the Amazon S3 console at https://console.aws.amazon.com/s3/.
Select the name of the bucket to open its details page.
Choose Permissions and then choose Bucket policy, Edit.
Update the bucket policy to grant the required permissions.
Choose Save changes.
Use the following procedure to configure access logs to capture request information and deliver log files to your S3 bucket.
RequirementsThe bucket must meet the requirements described in step 1, and you must attach a bucket policy as described in step 2. If you include a prefix, it must not include the string "AWSLogs".
To enable access logs for your load balancer using the consoleOpen the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
In the navigation pane, choose Load Balancers.
Select the name of your load balancer to open its details page.
On the Attributes tab, choose Edit.
For Monitoring, turn on Access logs.
For S3 URI, enter the S3 URI for your log files. The URI that you specify depends on whether you're using a prefix.
URI with a prefix: s3://amzn-s3-demo-logging-bucket
/logging-prefix
URI without a prefix: s3://amzn-s3-demo-logging-bucket
Choose Save changes.
Use the modify-load-balancer-attributes command.
To manage the S3 bucket for your access logsBe sure to disable access logs before you delete the bucket that you configured for access logs. Otherwise, if there is a new bucket with the same name and the required bucket policy but created in an AWS account that you don't own, Elastic Load Balancing could write the access logs for your load balancer to this new bucket.
Step 4: Verify bucket permissionsAfter access logs are enabled for your load balancer, Elastic Load Balancing validates the S3 bucket and creates a test file to ensure that the bucket policy specifies the required permissions. You can use the Amazon S3 console to verify that the test file was created. The test file is not an actual access log file; it doesn't contain example records.
To verify a test file was created in your bucket using the Amazon S3 consoleOpen the Amazon S3 console at https://console.aws.amazon.com/s3/.
Select the name of the bucket that you specified for access logs.
Navigate to the test file, ELBAccessLogTestFile
. The location depends on whether you're using a prefix.
Location with a prefix: amzn-s3-demo-logging-bucket
/logging-prefix
/AWSLogs/123456789012
/ELBAccessLogTestFile
Location without a prefix: amzn-s3-demo-logging-bucket
/AWSLogs/123456789012
/ELBAccessLogTestFile
If you receive an access denied error, the following are possible causes:
The bucket policy does not grant Elastic Load Balancing permission to write access logs to the bucket. Verify that you are using the correct bucket policy for the Region. Verify that the resource ARN uses the same bucket name that you specified when you enabled access logs. Verify that the resource ARN does not include a prefix if you did not specify a prefix when you enabled access logs.
The bucket uses an unsupported server-side encryption option. The bucket must use Amazon S3-managed keys (SSE-S3).
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4