<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gururajan Padmanaban</title>
    <description>The latest articles on DEV Community by Gururajan Padmanaban (@pgr405).</description>
    <link>https://dev.to/pgr405</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F886307%2Fb0b26340-86eb-49e7-8573-a87d5a8f25bc.jpg</url>
      <title>DEV Community: Gururajan Padmanaban</title>
      <link>https://dev.to/pgr405</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pgr405"/>
    <language>en</language>
    <item>
      <title>#AWS - Quicksight(SSO) user management.</title>
      <dc:creator>Gururajan Padmanaban</dc:creator>
      <pubDate>Sun, 17 Jul 2022 19:21:45 +0000</pubDate>
      <link>https://dev.to/pgr405/aws-quicksightsso-user-management-f6j</link>
      <guid>https://dev.to/pgr405/aws-quicksightsso-user-management-f6j</guid>
      <description>&lt;h2&gt;
  
  
  Scenario:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Consider that our AWS Quicksight account is configured with SSO for visualizing product metrics and you want to manage the Quicksight users.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Requirement:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;User activity monitoring, including last login, resource usage, dashboard popularity, etc…&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Issue:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Currently, in QuickSight there is no feature that allows you to see the activity of your users' metrics directly.
QuickSight users are charged monthly, even if the user does not sign in to the account.
You can expect a full month's charge, even if a user is removed before the end of the month.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;To keep track of user activity and identify inactive users.&lt;/li&gt;
&lt;li&gt;To notify inactive users to remind them.&lt;/li&gt;
&lt;li&gt;Delete the user automatically if the user has not been active for n days.&lt;/li&gt;
&lt;li&gt;Make improvements to the dashboards with the lowest visits.&lt;/li&gt;
&lt;li&gt;To decommission the dashboards that are less popular.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Solution:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Everything is an API call when it comes to AWS.&lt;/li&gt;
&lt;li&gt;Each activity will be logged in to Cloudtrail.&lt;/li&gt;
&lt;li&gt;We can use Amazon CloudTrail logs to gather information on user/dashboard activity
.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Quicksight Account Access:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When the user login to AWS if the user account is not available in Quicksight the same will be created.&lt;/li&gt;
&lt;li&gt;Once the user account is created based on the role and permissions provided, the user can access Quicksight resources such as Dashboards, Analysis, DataSets, etc…&lt;/li&gt;
&lt;li&gt;CloudTrail records actions taken by a user, role, or an AWS service in Amazon QuickSight.&lt;/li&gt;
&lt;li&gt;CloudTrail will log the following events for Quicksight:&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Data source&lt;/strong&gt; create/update/delete&lt;br&gt;
&lt;strong&gt;Data set&lt;/strong&gt; create/update/delete&lt;br&gt;
&lt;strong&gt;Analysis&lt;/strong&gt; create/access/update/delete&lt;br&gt;
&lt;strong&gt;Dashboard&lt;/strong&gt; create/access/update/delete, etc…&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Quicksight user activity monitoring process:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://aws.amazon.com/blogs/big-data/building-an-administrative-console-in-amazon-quicksight-to-analyze-usage-metrics/"&gt;Direct user activity monitoring&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once the SSO tool is integrated with Quicksight, users can use the tool to log in to Quicksight.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Most of the tools use &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_saml.html"&gt;SAML&lt;/a&gt; (Security Assertion Markup Language 2.0) to federate users into AWS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The only way to monitor the user activity out of the box is via Quicksight Manage Console only.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;By using the AWS API/CLI/SDK we can collect the required information from Cloudtrail.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SSO will use the AWS &lt;a href="https://docs.aws.amazon.com/STS/latest/APIReference/welcome.html"&gt;STS&lt;/a&gt; (Security Token Service) to request temporary, limited-privilege credentials for federated users.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The federated user will be provisioned to perform the &lt;strong&gt;sts:AssumeRoleWithSAML&lt;/strong&gt; action to access Quicksight resources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The SSO user login activity will be logged under {'Event' : 'AssumeRoleWithSAML'}&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Other activities will be logged under {'Event' : &lt;strong&gt;['CreateUser', 'DeleteUser', 'UpdateUser', 'GetDashboard', 'GetAnalysis']&lt;/strong&gt;}&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;By filtering the events based on the event name we can get the list of all activities from CloudTrail.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;From the CloudTrail log, we can get the user identity details such as event time, type, username, identity provider, etc…&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Code sample:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://docs.aws.amazon.com/cli/latest/reference/cloudtrail/lookup-events.html"&gt;AWS CLI:&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws cloudtrail lookup-events - lookup-attributes AttributeKey=EventName,AttributeValue=GetDashboard
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;a href="https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_LookupEvents.html"&gt;AWS API:&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   "EndTime": number,
   "EventCategory": "string",
   "LookupAttributes": [ 
      { 
         "AttributeKey": "string",
         "AttributeValue": "string"
      }
   ],
   "MaxResults": number,
   "NextToken": "string",
   "StartTime": number
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudtrail.html#CloudTrail.Client.lookup_events"&gt;Boto SDK:&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;response = client.lookup_events(
    LookupAttributes=[
        {
            'AttributeKey': 'EventId'|'EventName'|'ReadOnly'|'Username'|'ResourceType'|'ResourceName'|'EventSource'|'AccessKeyId',
            'AttributeValue': 'string'
        },
    ],
    StartTime=datetime(2015, 1, 1),
    EndTime=datetime(2015, 1, 1),
    EventCategory='insight',
    MaxResults=123,
    NextToken='string'
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Sample response:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "userIdentity": {
        "type": "AssumedRole",
        "principalId": "&amp;lt;principal_id&amp;gt;: &amp;lt;user_name&amp;gt;",
        "arn": "arn:aws:sts:: &amp;lt;aws_account_id&amp;gt;:assumed-role/&amp;lt;IAM_role_ name&amp;gt;/&amp;lt;user_name&amp;gt;",
        "accountId": "&amp;lt;aws_account_id&amp;gt;",
        "sessionContext": {
            "sessionIssuer": {
                "type": "Role",
                "principalId": "&amp;lt;principal_id&amp;gt;",
                …
            }
        }
    },
    "eventTime": "2022-17-13T16:55:36Z",
    "eventSource": "quicksight.amazonaws.com",
    "eventName": "GetDashboard",
    "awsRegion": "us-east-1",
    "eventID": "65ae334b-4202-4961-9ac7-d5a9d44416e2",
    "readOnly": true,
    "eventType": "AwsServiceEvent",
    "serviceEventDetails": {
        "eventRequestDetails": {
            "dashboardId": "arn:aws:quicksight:us-east-1: &amp;lt;aws_account_id&amp;gt;:dashboard/&amp;lt;dashboard_id&amp;gt;"
        },
        "eventResponseDetails": {
            "dashboardDetails": {
                "dashboardName": "Product X",
                "dashboardId": "arn:aws:quicksight:us-east-1: &amp;lt;aws_account_id&amp;gt;:dashboard/&amp;lt;dashboard_id&amp;gt;",
                "analysisIdList": [
                    "arn:aws:quicksight:us-east-1: &amp;lt;aws_account_id&amp;gt;:analysis/&amp;lt;analysis_id&amp;gt;"
            }
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/quicksight.html#QuickSight.Client.delete_user"&gt;Delete user:&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;response = client.delete_user(
    UserName='string',
    AwsAccountId='string',
    Namespace='string'
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Here are a few things to keep in mind:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CloudTrail keeps the logs for 90 days only.&lt;/li&gt;
&lt;li&gt;QuickSight users are charged monthly, even if the user does not sign in to the account.&lt;/li&gt;
&lt;li&gt;You can expect an entire month's charge, even if a user is removed before the end of the month.&lt;/li&gt;
&lt;li&gt;QuickSight users are charged based on QuickSights Edition (Standard/Enterprise)&lt;/li&gt;
&lt;li&gt;QuickSight Readers are charged per reader session basis, and sessions are in 30-minute increments. Each session costs $0.30, per reader, up to a maximum of $5 per reader per month (month-to-month).&lt;/li&gt;
&lt;li&gt;If a Reader has a dashboard open, the timer will continue to run(in 30min increments), until the Reader closes or minimizes the dashboard window.&lt;/li&gt;
&lt;li&gt;If a Reader opens a dashboard and closes the dashboard before the 30min of the session expires, the timer will stop at 30min and will not continue to run.&lt;/li&gt;
&lt;li&gt;10GB of SPICE capacity is provisioned to the QuickSight account for each user added, at no additional cost.&lt;/li&gt;
&lt;li&gt;Additional SPICE can be purchased at $0.38 per GB/month.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Once the required data is available from CloudTrail we can store the data in S3 and use the same to manage the Quicksight account. We use a simple Lambda function that can automatically remove inactive users. We can also set up a trigger for the lambda function using Cloudwath (Cron job).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;FAQs:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Question:&lt;/strong&gt; If a user was added and deleted at any point of a month, the charge would be added for the days he was active right?&lt;br&gt;
&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No, If the Author/Admin user is removed from the account, you are still billed for that user for the month (starting from the day they were listed as active). If the user was already listed on the account from day 1 of the month, you could expect the full monthly charge. If the user was only added to the account partway through the month (say, on the 10th day) then you will only receive a total charge that calculates up to the remaining days of the month, you will not be charged for the 10 days the user was not listed as active.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; When an ADMIN / AUTHOR is working on a Resource (Analysis / Dashboard etc….). Will that be charged in any way?&lt;br&gt;
&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users are charged per month, regardless of their sign-in activity, or use of resources on the account. It is a monthly charge.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; If a READER is active in a day the sessions will be charged if the Max $5 USD is not reached already, correct?&lt;br&gt;
&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The user will be charged based on the time a dashboard is open. For example,&lt;/li&gt;
&lt;li&gt;A Reader opens a dashboard for 1hr, 2x 30min sessions. Considering each session is charged at $0.30 per 30min session, this particular Reader will be charged $0.60 ($0.30 x 2 (30min + 30min) = $0.60).&lt;/li&gt;
&lt;li&gt;If the Reader leaves the dashboard open and is visible at all times, for 16 hours, then the charge for that user will be $5 for that day. However, since there is a maximum charge of $5 per month, you will not see any further billing for that specific Reader.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; If a user is added on the 5th and deleted on the 6th will there be any charge?&lt;br&gt;
&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Since users are charged monthly, you will be charged from the 5th until the last day of the same month, thereafter you will not be charged for the removed user. This is why user charges are displayed daily on the Billing Console.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; If we were to get a subscription for all our ADMIN / AUTHOR (8 Users) how much cost it will save?&lt;br&gt;
&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For the Enterprise Edition of QuickSight, paying month-to-month, you will pay $192 for the 8 users ($24 per user/month * 8 users = $192)&lt;/li&gt;
&lt;li&gt;The Annual Subscription is $18 per user per month. This means you will pay $144 per month for the 8 users, saving you $48 monthly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/blogs/aws/single-sign-on-between-okta-universal-directory-and-aws/"&gt;Single Sign-On between Okta Universal Directory and AWS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/blogs/big-data/federate-amazon-quicksight-access-with-okta/"&gt;Federate amazon Quicksight access with okta&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/blogs/big-data/building-an-administrative-console-in-amazon-quicksight-to-analyze-usage-metrics/"&gt;Building an administrative console in Amazon QuickSight to analyze usage metrics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/quicksight/latest/user/logging-using-cloudtrail.html"&gt;Logging Operations with AWS CloudTrail&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/athena/latest/ug/cloudtrail-logs.html"&gt;Manually Creating the Table for CloudTrail Logs in Athena&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/blogs/big-data/aws-cloudtrail-and-amazon-athena-dive-deep-to-analyze-security-compliance-and-operational-activity/"&gt;Analyse Security, Compliance, and Operational Activity Using AWS CloudTrail and Amazon Athena&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/blogs/big-data/amazon-quicksight-now-supports-audit-logging-with-cloudtrail/"&gt;Amazon QuickSight Now Supports Audit Logging with AWS CloudTrail&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/quicksight/latest/user/logging-non-api.html"&gt;Tracking Non-API Events by Using CloudTrail Logs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/athena/latest/ug/cloudtrail-logs.html#create-cloudtrail-table-understanding"&gt;Querying AWS CloudTrail Logs - Understanding CloudTrail Logs and Athena Tables&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
    </item>
    <item>
      <title>Answer: How QuickSight SPICE refresh the data</title>
      <dc:creator>Gururajan Padmanaban</dc:creator>
      <pubDate>Wed, 13 Jul 2022 03:50:27 +0000</pubDate>
      <link>https://dev.to/pgr405/answer-how-quicksight-spice-refresh-the-data-3h3</link>
      <guid>https://dev.to/pgr405/answer-how-quicksight-spice-refresh-the-data-3h3</guid>
      <description>&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7Gn-iPj_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/58709782/how-quicksight-spice-refresh-the-data/72960623#72960623" rel="noopener noreferrer"&gt;
            &lt;span class="title-flare"&gt;answer&lt;/span&gt; re: How QuickSight SPICE refresh the data
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Jul 13 '22&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/58709782/how-quicksight-spice-refresh-the-data/72960623#72960623" rel="noopener noreferrer"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y9mJpuJP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          0
        &lt;/div&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wif5Zq3z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;My data is in parquet format. I guess Quicksight does not support a direct query on s3 parquet data.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Yes, we need to use Athena to read the parquet.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When you say point QuickSight to S3 directly, do you mean without SPICE?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Don't do it, it will increase the Athena…&lt;/li&gt;
&lt;/ul&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/58709782/how-quicksight-spice-refresh-the-data/72960623#72960623" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Answer&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title># AWS - Athena query result management FAQs</title>
      <dc:creator>Gururajan Padmanaban</dc:creator>
      <pubDate>Tue, 12 Jul 2022 18:35:13 +0000</pubDate>
      <link>https://dev.to/pgr405/-aws-athena-query-result-management-faqs-58le</link>
      <guid>https://dev.to/pgr405/-aws-athena-query-result-management-faqs-58le</guid>
      <description>&lt;p&gt;&lt;strong&gt;How to set up the query result location?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The query result location that Athena uses is determined by a combination of workgroup settings and client-side settings.&lt;/li&gt;
&lt;li&gt;Athena console, (Athena -&amp;gt; Query Editor -&amp;gt; Settings  -&amp;gt; Manage Settings).&lt;/li&gt;
&lt;li&gt;The workgroup settings can be specified using the console, CLI, or API.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Can we override the query result location?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Yes, each workgroup setting has an Override client-side settings option that can be enabled. &lt;/li&gt;
&lt;li&gt;When this option is enabled, the workgroup settings take precedence over the applicable client-side setting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Will changing the result location affect the existing process?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Changing the query result location will not affect the existing process.&lt;/li&gt;
&lt;li&gt;The result is saved in the new location.&lt;/li&gt;
&lt;li&gt;Ensure that the new location is accessible by your existing processes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Is Athena regional service or Availability Zone-based service?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Athena is a regional service.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is a saved query?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Athena allows the user to save the query in the console, the saved query results will be stored in the specified query result location in the following format QueryName/yyyy/mm/dd/ &lt;/li&gt;
&lt;li&gt;Query Result Location: QueryResultsLocationInS3/[QueryName|Unsaved/yyyy/mm/dd/]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why are the API query results stored directly?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only queries run from the console whose results path has not been overridden by workgroup settings store results using this path structure: QueryName/yyyy/mm/dd/.&lt;/li&gt;
&lt;li&gt;Queries that run from the AWS CLI or using the Athena API are saved directly to the QueryResultsLocationInS3&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Does Athena cache query results?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No, Athena doesn't support query caching.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How to trigger saved queries via API / CLI?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Athena does not support trigger-saved queries via CLI/API directly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Is there a Workaround to trigger the saved queries via API?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use the ListNamedQueries API to grab the saved queries' IDs. &lt;/li&gt;
&lt;li&gt;Using this resulting list, you can then loop through the list running GetNamedQuery on each query ID.&lt;/li&gt;
&lt;li&gt;Once you have found the saved query that you are looking for, you can then run StartQueryExecution using the resulting values from the GetNamedQuery operation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Can we store the results in a specific folder via API or CLI?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Yes, bypassing the OutputLocation via the API or CLI.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Can we use saved queries and store the results based on saved query name folders in s3?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Yes, however this only works with queries run from the console whose results path has not been overridden by workgroup settings &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Can we use saved queries in Quicksight?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No, we can not directly use saved queries in Quicksight. You would need to copy the query and use the custom SQL option in QuickSight to create a dataset from it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How to monitor Athena's activity?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We can collect the query execution details such as 

&lt;ul&gt;
&lt;li&gt;Query string&lt;/li&gt;
&lt;li&gt;Data scanned &lt;/li&gt;
&lt;li&gt;Scanned time &lt;/li&gt;
&lt;li&gt;Database&lt;/li&gt;
&lt;li&gt;Table &lt;/li&gt;
&lt;li&gt;Time etc.
From Cloudtrail. 
Keep in mind that Cloudtrail will only keep the logs for 90 days.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How to keep the Athena query execution details for longer?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Periodically we can collect the Cloud Trial Athena logs and store them in S3 for future reference. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is the maximum Query string length?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The fixed maximum allowed query string length is 262144 bytes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Which encoding is used in Athena?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UTF-8.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Is there a cost involved for canceled queries?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Canceled queries are charged based on the amount of data scanned.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Is there a cost involved for failed queries?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There are no charges for failed queries.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is the minimum amount of scanned data considered for billing?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;10MB minimum per query.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why is the sorting in S3 not working?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To enable sorting in the S3, use the search to reduce the size of the list to 999 objects or fewer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How to delete huge amounts of data, i.e: 18000 files?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There is no direct way from Athena's side to delete the files from the result location. Please consider using the s3 lifecycle policy to delete objects older than a specific time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Is it safe to delete the old file (More than 45 days or 90 Days)? If yes, how do we do it?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can safely delete the old files as long as you don't want to go back and review the results of that particular query at the time it was run. &lt;/li&gt;
&lt;li&gt;If you delete the data and then decide you wish to know the results of that query again, you will then have to re-run the query. &lt;/li&gt;
&lt;li&gt;AWS does not recommend deleting the Query metadata files as this will cause important information on the query to be lost, however, you are still welcome to do this as long as you do not require information on that query anymore.&lt;/li&gt;
&lt;li&gt;You can delete the files from your S3 bucket by navigating to the S3 bucket in the S3 console, selecting the files you wish to delete, and clicking delete. &lt;/li&gt;
&lt;li&gt;You can also set a lifecycle configuration on the bucket if you wish to prevent the retention of S3 objects past a certain length of time &lt;a href="https://dev.to/pgr405/aws-set-up-s3-lifecycle-for-data-rotation-580l"&gt;S3 Lifecycle&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Will deleting the data cause any error?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you select to view a query in the Athena "Recent queries" tab for which you have already deleted the data then you will receive an error message "Could not find results". You can then re-run the query to fetch new results.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Do we need to take a backup?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Whether you decide to delete the data or keep it for future use, backing it up or not, is up to you and your use case. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Can we use the stored query results in SQL Query?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can create a table using a query result file if you want using CREATE EXTERNAL TABLE, the same way you would with any other CSV file. You can also use CREATE TABLE AS SELECT, a view, or the WITH clause if you wish to use the results of an Athena query in another query however please note these methods will not utilize the old results file but will re-run the query instead.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How to query the results file?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you wish to create a table on the CSV results file, then you must move the file into a new folder that contains only the data to be scanned in the new table. If any other files are present you may encounter errors as Athena can not recognize exclusion patterns. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Reference:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/athena/latest/ug/other-notable-limitations.html"&gt;limitations for SQL queries in Athena&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/premiumsupport/knowledge-center/athena-query-results/"&gt;Use the results in another query&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/athena/latest/ug/tables-location-format.html"&gt;Table location for creating a table&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/athena/latest/ug/querying.html#:~:text=Identifying%20query%20output%20files"&gt;Identifying query output files&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/athena/latest/APIReference/API_ListNamedQueries.html"&gt;Trigger saved queries via API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/athena/latest/ug/querying.html"&gt;Working with query results&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/athena/latest/ug/creating-tables.html#creating-tables-how-to"&gt;Creating tables in Athena&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/athena/latest/ug/querying.html#querying-finding-output-files"&gt;Query output files in S3&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html"&gt;CloudTrail Event history&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html"&gt;Viewing recent queries&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/athena/latest/ug/querying.html#query-results-specify-location"&gt;Query result location&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/athena/latest/ug/service-limits.html"&gt;Service Quotas&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/athena/latest/ug/saved-queries.html"&gt;Saved queries&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
    </item>
    <item>
      <title>#AWS - Athena query result management.</title>
      <dc:creator>Gururajan Padmanaban</dc:creator>
      <pubDate>Tue, 12 Jul 2022 17:43:40 +0000</pubDate>
      <link>https://dev.to/pgr405/aws-athena-query-result-management-289n</link>
      <guid>https://dev.to/pgr405/aws-athena-query-result-management-289n</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is Athena?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Amazon Athena is a serverless interactive query service that makes it easy to analyze data in Amazon S3 using standard SQL&lt;/li&gt;
&lt;li&gt;It is a “pay as you go service”, you pay only for the queries that you run&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How does it work?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Athena uses Presto under the hood to run queries. Presto is a distributed query engine for big data using the SQL query language. &lt;/li&gt;
&lt;li&gt;Athena also uses Apache Hive. Apache Hive gives an SQL-like interface to query data stored in various databases and file systems that integrate with Hadoop&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What are Athena's query results?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Athena stores query results and metadata information for each query that runs automatically.&lt;/li&gt;
&lt;li&gt;These results are stored in an S3 bucket that we can specify.&lt;/li&gt;
&lt;li&gt;We can also encrypt the files if required.&lt;/li&gt;
&lt;li&gt;Athena supports DML, and DDL queries. &lt;/li&gt;
&lt;li&gt;Files are saved based on the name of the query, and the query ID. QueryID is a unique identifier that Athena assigns to each query when it runs. I.e: 0000e975-9f92-4adb-b853-71fc97dac20e.csv&lt;/li&gt;
&lt;li&gt;For each query, the result will contain two files

&lt;ol&gt;
&lt;li&gt;Actual data&lt;/li&gt;
&lt;li&gt;Metadata&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;DML query results are saved (CSV) format.&lt;/li&gt;
&lt;li&gt;DDL query results are saved as plain text files.&lt;/li&gt;
&lt;li&gt;Metadata files are saved in binary format.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What are DML and DDL?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DDL (Data Definition Language) queries include CREATE TABLE and ALTER TABLE ADD PARTITION. ​​&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There are no charges for DDL queries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;DML (Data Manipulation Language) queries include SELECT, CREATE TABLE AS (CTAS), and INSERT INTO queries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;DML queries are charged for the number of bytes scanned rounded up to the nearest megabyte&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is a query quota?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A number of queries can be executed at any given time. &lt;/li&gt;
&lt;li&gt;Query quota includes both running and queued queries. &lt;/li&gt;
&lt;li&gt;Exhausting the query will result in a TooManyRequestsException error.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How to access the query results?&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We can directly access/download the files from Athena Console/S3.&lt;/li&gt;
&lt;li&gt;We can use AWS CLI / API to get the query results from Athena based on the unique QueryIds. &lt;/li&gt;
&lt;li&gt;To access and view query output files, IAM principals (users and roles) need permission for the Amazon S3 GetObject action for the query result location, as well as permission for the Athena GetQueryResults action. &lt;/li&gt;
&lt;li&gt;If the location is encrypted, users must have the appropriate key permissions to encrypt and decrypt the query result location.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why should we bother?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Athena keeps a query history for 45 days.&lt;/li&gt;
&lt;li&gt;CloudTrail keeps the log for 90 days.&lt;/li&gt;
&lt;li&gt;But the Athena query results are kept forever.&lt;/li&gt;
&lt;li&gt;Over a period of time, the query results get accumulated and incur a cost when kept in S3.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What can we do?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Setup a data rotation policy to maintain the Athena query results. &lt;/li&gt;
&lt;li&gt;This can be achieved using S3 lifecycle policies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*&lt;em&gt;Is there a risk involved in deleting the query results? *&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can safely delete the old files as long as you don't want to go back and review the results of that particular query.&lt;/li&gt;
&lt;li&gt;But keep in mind once the data is deleted it can’t be restored.&lt;/li&gt;
&lt;li&gt;Also while trying to access the result will throw a "Could not find results" error.&lt;/li&gt;
&lt;li&gt;We can always run the query to get the results again.&lt;/li&gt;
&lt;li&gt;For any reason such as unexpected Athena usage, if we want the query results we will not be able to get them. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What are the best practices to be followed?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use Athena Saved queries wherever possible. &lt;/li&gt;
&lt;li&gt;Create and maintain a separate bucket for Athena query results. &lt;/li&gt;
&lt;li&gt;Setup an S3 lifecycle to maintain the query results.&lt;/li&gt;
&lt;li&gt;Set Up a monitoring system for collecting and storing the Athena logs periodically into the S3 bucket from Cloud Trail.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Reference:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/athena/?whats-new-cards.sort-by=item.additionalFields.postDateTime&amp;amp;whats-new-cards.sort-order=desc"&gt;Amazon Athena&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cwiki.apache.org/confluence/display/Hive/"&gt;Apache Hive&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://prestodb.io/docs/current/"&gt;Prestodb&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/athena/pricing/#:~:text=into%20columnar%20formats.-,Pricing%20details,-You%20are%20charged"&gt;Pricing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/cli/latest/reference/athena/start-query-execution.html"&gt;Start-query-execution&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/athena/latest/ug/querying.html"&gt;Working with query results&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pgr405/aws-set-up-s3-lifecycle-for-data-rotation-580l"&gt;S3 Lifecycle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pgr405/aws-s3-lifecycle-faq-3hm2"&gt;S3 Lifecycle FAQs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
    </item>
    <item>
      <title>#AWS - Set up S3 Lifecycle for data rotation</title>
      <dc:creator>Gururajan Padmanaban</dc:creator>
      <pubDate>Mon, 11 Jul 2022 15:55:27 +0000</pubDate>
      <link>https://dev.to/pgr405/aws-set-up-s3-lifecycle-for-data-rotation-580l</link>
      <guid>https://dev.to/pgr405/aws-set-up-s3-lifecycle-for-data-rotation-580l</guid>
      <description>&lt;p&gt;&lt;strong&gt;Requirement:&lt;/strong&gt; Delete all or specified objects after n days.&lt;/p&gt;

&lt;h3&gt;
  
  
  S3 Lifecycle rules:
&lt;/h3&gt;

&lt;p&gt;An S3 Lifecycle configuration is a set of rules that define actions that Amazon S3 applies to a group of objects. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;There are two types of actions:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Transition actions:&lt;/em&gt; These actions define when objects transition to another storage class. &lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Expiration actions:&lt;/em&gt; These actions define when objects expire. Amazon S3 deletes expired objects on your behalf.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Rules:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Move current versions of objects between storage classes&lt;/li&gt;
&lt;li&gt;Move noncurrent versions of objects between storage classes&lt;/li&gt;
&lt;li&gt;Expire the current version of the object &lt;/li&gt;
&lt;li&gt;Permanently delete the noncurrent versions of objects&lt;/li&gt;
&lt;li&gt;Delete expired object delete markers or incomplete multipart uploads (Will does not work if the rules are scoped with tags)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For our process, we are going to focus on the data rotation rules (3 to 5). Other rules are related to the data retention policy, where we move the objects from one S3 class to another S3 class according to our requirements such as how frequently we need to access them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scope:
&lt;/h3&gt;

&lt;p&gt;We can apply these rules to all objects in the bucket or limit the rule's scope using one or more filters.&lt;/p&gt;

&lt;h3&gt;
  
  
  Filters:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prefix:&lt;/strong&gt; Provide a prefix based on which the files will be marked as expired. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;File size:&lt;/strong&gt; We can configure a filter to delete the object only if the file size is more than a certain limit.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Tags (Paid service):
&lt;/h3&gt;

&lt;p&gt;AWS supports tag objects according to our requirements. Tags are &lt;a&gt;key:value&lt;/a&gt; pairs e.g: Expire:True. By using these tags we can set up a filter to delete only the tagged objects.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tags are charged monthly. It is a recurring cost.&lt;/p&gt;

&lt;p&gt;To set up a tag for an object also need to pay for the API calls.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Versioning:
&lt;/h3&gt;

&lt;p&gt;To protect the object from being overwritten or deleted S3 provides version support so that we can restore the previous versions if required.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Unversioned:&lt;/strong&gt; This is the default state for any bucket, if the bucket is not version enabled then all the objects are expired and deleted simultaneously. It is &lt;em&gt;not necessary to set up any other rule to delete the expired object.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Version enabled:&lt;/strong&gt;  If a bucket is a version enabled then we need to explicitly set up a rule to delete the old objects. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rule:&lt;/strong&gt; ”Permanently delete the noncurrent versions of objects” &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Multipart uploads:
&lt;/h3&gt;

&lt;p&gt;Uploading large files in chunks. S3 supports multipart uploads out of the box (If an object is more than 100 MB). &lt;/p&gt;

&lt;p&gt;*Block storage process is supported *&lt;br&gt;
I.e:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We can upload the parts/chunks in any order.
&lt;/li&gt;
&lt;li&gt;If any part fails during upload, we can upload that part only without affecting other parts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the upload fails then the incomplete parts get accumulated over a period of time. To avoid such scenarios we can set up a rule to delete those incomplete parts of objects from s3 by using the rule “Delete expired object delete markers or incomplete multipart uploads”. &lt;/p&gt;

&lt;h3&gt;
  
  
  Expiration of an object:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Every day at zero time (UTC) the rule will be invoked. &lt;/li&gt;
&lt;li&gt;Every rule will be invoked simultaneously.&lt;/li&gt;
&lt;li&gt;When the rule is invoked the object must satisfy the rule.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;E.g:&lt;/strong&gt; If you set up a rule to expire an object after 1 day in IST  and the rule is triggered at zero time UTC and the object does not satisfy the rule equal to or older than 1 day, then the object will not be marked as expired. &lt;/li&gt;
&lt;li&gt;Always keep the timezone in mind when setting up a rule. AWS S3 is in the UTC timezone.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example expiration process workflow:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Object uploaded: 6 July 09:18 UTC&lt;/li&gt;
&lt;li&gt;Lifecycle Rule for expiring objects after 1 day, ran on: 7 July 00:00 UTC&lt;/li&gt;
&lt;li&gt;By this time the object had not completed 24 Hrs in the S3 Bucket&lt;/li&gt;
&lt;li&gt;Then your Object was completed 24 Hrs in the S3 Bucket on 7 July at 9:18 UTC&lt;/li&gt;
&lt;li&gt;The next Lifecycle rule is scheduled to run on: 8 July at 00:00 UTC&lt;/li&gt;
&lt;li&gt;&lt;p&gt;At this point, the Lifecycle rule marked the object for expiration with the expiration date as 8 July 00:00 UTC&lt;br&gt;
i.e. 8 July 5:30 AM in Indian Standard Time. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Lifecycle rules run at 12 AM Midnight UTC and will mark the object for expiration, which are eligible as per the rule specified. S3 rounds the expiration time to midnight UTC the next day, which explains why the object was marked for expiration on 8th July instead of 7th July. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Deleting the object:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The expired objects will not be deleted immediately, S3 will asynchronously remove these from the Bucket on the backend. &lt;/li&gt;
&lt;li&gt;This can take some time to complete as S3 performs this operation while ensuring that the service remains available. &lt;/li&gt;
&lt;li&gt;However, since the object is marked for expiration we will not be charged for the storage of the same, even though the object might still be visible in the S3 Bucket.&lt;/li&gt;
&lt;li&gt;We can access the objects even if they are expired. &lt;/li&gt;
&lt;li&gt;The entire folder will be deleted if there are no files left. Because S3 is an object-based storage class anything and everything is an object so even though we access it like a normal file system (Folders and Files) it is actually an object. So every object which satisfies the rule will expire.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Overlapping rules:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;When setting up a rule if one rule overlaps another AWS will always go with the rule which is the &lt;strong&gt;least expensive and save more&lt;/strong&gt; w.r.t cost. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rule one is set up to migrate the objects from the S3 Standard class to S3 Infrequent Access after 90 days.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then the second rule is set up to expire the objects after 90 days.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;AWS will always go with the second rule because there is no point in migrating the objects if we are going to delete them anyway.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Limitations:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Suffixes are not supported, i.e if we want to delete only a specific file type e.g: .csv we can't use a filter like *.csv.&lt;/li&gt;
&lt;li&gt;The entire folder will be deleted if there are no files left. There’s no way around it.&lt;/li&gt;
&lt;li&gt;To delete a specific file we need to use tags.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Steps to create a lifecycle rule to expire objects:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Sign in to the AWS Management Console and open the Amazon S3 console&lt;/li&gt;
&lt;li&gt;In the Buckets list, choose the name of the bucket that you want to create a lifecycle rule.&lt;/li&gt;
&lt;li&gt;Choose the Management tab, and choose to Create lifecycle rule.&lt;/li&gt;
&lt;li&gt;In the Lifecycle rule name, enter a name for your rule.&lt;/li&gt;
&lt;li&gt;Choose the scope of the lifecycle rule:

&lt;ul&gt;
&lt;li&gt;To limit the scope by prefix, in Prefix, enter the prefix&lt;/li&gt;
&lt;li&gt;Enter the object tag key&lt;/li&gt;
&lt;li&gt;Object size - specify the minimum object or maximum object size&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Under Lifecycle rule actions, choose the actions that you want your lifecycle rule to perform:

&lt;ul&gt;
&lt;li&gt;Expire current versions of objects&lt;/li&gt;
&lt;li&gt;Permanently delete previous versions of objects (if that fits your use case)&lt;/li&gt;
&lt;li&gt;Delete expired delete markers or incomplete multipart uploads (if that fits your use case)
Depending on the actions that you choose, different options appear.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;To expire current versions of objects, under Expire previous versions of objects, in the Number of days after object creation, enter the number of days(45 days).&lt;/li&gt;
&lt;li&gt;To permanently delete previous versions of objects, under Permanently delete previous versions of objects, in Number of days after objects become previous versions, enter the number of days.&lt;/li&gt;
&lt;li&gt;Under Delete expired delete markers or incomplete multipart uploads, choose to Delete expired object delete markers and Delete incomplete multipart uploads. Then, enter the number of days after the multipart upload initiation that you want to end and clean up incomplete multipart uploads.&lt;/li&gt;
&lt;li&gt;Choose Create rule.
If the rule does not contain any errors, Amazon S3 enables it, and you can see it on the Management tab under Lifecycle rules.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Ref:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/how-to-set-lifecycle-configuration-intro.html"&gt;Lifecycle configuration intro&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html"&gt;Managing your storage lifecycle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html#intro-lifecycle-rules-number-of-days"&gt;Lifecycle rules: Based on an object's age&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/blogs/storage/simplify-your-data-lifecycle-by-using-object-tags-with-amazon-s3-lifecycle/"&gt;Simplify your data lifecycle by using object tags with Amazon S3 Lifecycle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html#intro-lifecycle-rules-filter"&gt;Lifecycle rules filter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/about-aws/whats-new/2021/11/amazon-s3-lifecycle-storage-cost-savings/"&gt;Amazon s3 lifecycle storage cost savings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/about-aws/whats-new/2011/12/27/amazon-s3-announces-object-expiration/"&gt;Amazon S3 Object Expiration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/s3/pricing/"&gt;Amazon S3 pricing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/premiumsupport/knowledge-center/s3-empty-bucket-lifecycle-rule/"&gt;Empty the S3 bucket using a lifecycle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-class-intro.html#sc-glacier"&gt;Storage classes for archiving objects&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-class-intro.html#sc-compare"&gt;Comparing the Amazon S3 storage classes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/s3/storage-classes/"&gt;Amazon S3 Storage Classes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/s3/pricing/https://aws.amazon.com/premiumsupport/knowledge-center/glacier-early-delete-fees"&gt;Early delete fees&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/premiumsupport/knowledge-center/s3-lifecycle-rule-delay/"&gt;s3 lifecycle rule delay&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html#:~:text=When%20specifying%20the,object%20or%20objects"&gt;Lifecycle rules: Based on an object's age&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html"&gt;Lifecycle configuration elements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-configuration-examples.html#lifecycle-config-conceptual-ex5"&gt;Examples of S3 Lifecycle configuration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html#:~:text=Expiration%20deletes%20the%20object%2C%20and%20the%20deleted%20object%20cannot%20be%20recovered"&gt;Data recovery&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
    </item>
    <item>
      <title>#AWS - Increase your Quicksight SPICE data refresh frequency.</title>
      <dc:creator>Gururajan Padmanaban</dc:creator>
      <pubDate>Mon, 11 Jul 2022 15:51:57 +0000</pubDate>
      <link>https://dev.to/pgr405/aws-increase-your-quicksight-spice-data-refresh-frequency-442b</link>
      <guid>https://dev.to/pgr405/aws-increase-your-quicksight-spice-data-refresh-frequency-442b</guid>
      <description>&lt;h1&gt;
  
  
  Scenario:
&lt;/h1&gt;

&lt;p&gt;Let us say I want to fetch the data from the source (Jira) and push it to SPICE and render it in Quicksight Dashboards. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Requirement:&lt;/strong&gt; &lt;br&gt;
  Push the data every 30 Mins once.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Quicksight supports the following: *&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Full refresh
&lt;/li&gt;
&lt;li&gt;Incremental refresh&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Full refresh:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Process - Old data is replaced with new data. &lt;/li&gt;
&lt;li&gt;  Frequency - Every 1 Hr once &lt;/li&gt;
&lt;li&gt;  Refresh count - &lt;strong&gt;24 /  Day&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Incremental refresh:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Process - New data get appended to the dataset. &lt;/li&gt;
&lt;li&gt;  Frequency - Every 15 Min once &lt;/li&gt;
&lt;li&gt;  Refresh count - &lt;strong&gt;96 / Day&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  Issue:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;We need to push the data every 30 Min once.&lt;/li&gt;
&lt;li&gt;It is going to be a &lt;strong&gt;FULL_REFRESH&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;When it comes to &lt;em&gt;Full Refresh&lt;/em&gt; Quicksight only supports &lt;em&gt;Hourly&lt;/em&gt; refresh.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  Solution:
&lt;/h1&gt;

&lt;p&gt;We can leverage API support from AWS. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Package - Python Boto 3&lt;/li&gt;
&lt;li&gt;Class - Quicksight.client &lt;/li&gt;
&lt;li&gt;Method - create_ingestion&lt;/li&gt;
&lt;li&gt;Process - You can manually refresh datasets by starting new SPICE ingestion. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Refresh cycle:&lt;/strong&gt; Each 24-hour period is measured starting 24 hours before the current date and time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Limitations:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Enterprise edition&lt;/strong&gt; accounts 32 times in a 24-hour period. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Standard edition&lt;/strong&gt; accounts 8 times in a 24-hour period. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Sample code:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python - Boto for AWS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import boto3
client = boto3.client('quicksight')

response = client.create_ingestion(
    DataSetId='string',
    IngestionId='string',
    AwsAccountId='string',
    IngestionType='INCREMENTAL_REFRESH'|'FULL_REFRESH'
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;awswrangler:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import awswrangler as wr
wr.quicksight.cancel_ingestion(ingestion_id="jira_data_sample_refresh", dataset_name="jira_db")

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CLI:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws quicksight create-ingestion --data-set-id dataSetId --ingestion-id jira_data_sample_ingestion --aws-account-id AwsAccountId --region us-east-1

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;API:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PUT /accounts/AwsAccountId/data-sets/DataSetId/ingestions/IngestionId HTTP/1.1
Content-type: application/json

{
   "IngestionType": "string"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion:
&lt;/h1&gt;

&lt;p&gt;Using this approach we can achieve 56 Full Refreshes for our dataset also we can go one step further and get the peak hours of our source tool (Jira) and configure the data refresh accordingly. This way we can even achieve a refresh frequency of 10 Min once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ref:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/quicksight/pricing/"&gt;Quicksight&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/quicksight/gallery/"&gt;Quicksight Gallery&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/about-aws/whats-new/2020/07/amazon-quicksight-spice-data-engine-supports-data-sets-250m-rows/"&gt;SPICE&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html"&gt;Boto - Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/quicksight.html#QuickSight.Client.create_ingestion"&gt;Boto - Create Ingestion&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws-data-wrangler.readthedocs.io/en/stable/stubs/awswrangler.quicksight.cancel_ingestion.html#awswrangler.quicksight.cancel_ingestion"&gt;AWS Wrangler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/cli/latest/reference/quicksight/create-ingestion.html"&gt;CLI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/quicksight/latest/APIReference/API_CreateIngestion.html"&gt;API&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
    </item>
    <item>
      <title>#AWS - S3 Lifecycle FAQ</title>
      <dc:creator>Gururajan Padmanaban</dc:creator>
      <pubDate>Mon, 11 Jul 2022 15:48:37 +0000</pubDate>
      <link>https://dev.to/pgr405/aws-s3-lifecycle-faq-3hm2</link>
      <guid>https://dev.to/pgr405/aws-s3-lifecycle-faq-3hm2</guid>
      <description>&lt;h3&gt;
  
  
  FAQ:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; If we set up a life cycle will it be applied to the existing files?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ans:&lt;/strong&gt; Yes, the Lifecycle rule applies to all the data present inside the S3 bucket, whether it is uploaded before or after the addition of the lifecycle rule.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For example, you have two objects in your S3 bucket, one is 100 days old and the other was recently uploaded just 2 hours before. Now, You added a life cycle for expiring the objects after 30 days, the 100 days object will not wait for another 30 days but it will expire whenever the lifecycle rule runs first. The other recently uploaded object will wait to become 30 days old, and after that lifecycle will run on it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Can we set up a rule to delete the file under a specific folder? &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; Yes, if your files are being stored under a particular prefix then you can configure Lifecycle to only have the purview of that particular prefix. This way any other data uploaded to your S3 bucket would not be deleted.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Is it possible to read the expired objects in S3?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; It is possible but not guaranteed, that the object may or may not be readable after some time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Is it possible to trigger the lifecycle rule as per timezone?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; Lifecycle configs are executed and fully managed by AWS. AWS executes them at midnight UTC and their execution cannot be automated according to a specific time zone. Lifecycle rules will only execute at Midnight UTC. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Can we control the order in which the rules are invoked/executed?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; No, it is not possible as of now, the Lifecycle will come into play concurrently.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; How does expiration work in the case of buckets without versioning enabled?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; The expiration rule will permanently delete the object in case of a non-versioning bucket. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Do we need a second rule for deleting the expired objects in case of buckets without versioning?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; The second rule to permanently remove the delete markers is not needed in the case of a non-versioning enabled bucket.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Is it possible to recover the deleted objects?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; No, ​​deleted objects cannot be recovered.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; If the setup expires after 1 day and deletes after 1 day, will the delete rule wait for one more day after the object is expired?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ans:&lt;/strong&gt; In the case of a non-versioning bucket the above implementation will not make any difference and the object will be expired after 1 day. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When you are using a Versioning enabled Bucket, the first rule will create a delete marker of the object after 1 day. The second rule will wait for the delete marker to become 1 day old, and then it will permanently delete the marker. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;So your object will be deleted after 2 days. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;I.e:&lt;/strong&gt; If the period is set to 45 Days.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the case of the Non-versioning bucket - The object will get removed after 45 Days.
In case of Versioning enabled Bucket -&amp;gt; Object will be converted to delete marker after 45 Days -&amp;gt; Delete Marker will expire after another 45 days -&amp;gt; Total Time to permanent delete = 90 Days.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; When the expired data is deleted the entire folder is deleted instead of the files in that folder. How to avoid this and only delete the expired objects and keep the folder intact?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; Amazon S3 has a flat structure with no hierarchy as we would see in a typical file system. However, for the sake of organizational simplicity, the Amazon S3 console supports the folder concept as a means of grouping objects. Amazon S3 does this by using key name prefixes for objects. As for now, there is no way to keep the folder intact.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; What is the frequency of s3 lifecycle rules?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; S3 lifecycle only runs once a day at 00:00 UTC and tags the objects that fall under its purview for the actions that you have directed it to.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Why are the expired objects not deleted immediately? &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; S3 will asynchronously remove these from the Bucket on the backend. This can take some time to complete as S3 performs this operation while ensuring that the service remains available. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Will there be a delay in deleting the files?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; Yes, if you have a large number of objects, therefore, it might cause a delay in the deletion of objects.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Is the expired object charged? &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; Once the lifecycle has tagged the data for deletion, then you do not incur any charges for the storage. For example, if an object is scheduled to expire and Amazon S3 does not immediately expire the object, you won't be charged for storage after the expiration time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Is there any cost for the S3 life cycle?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; There is no cost for applying the S3 lifecycle. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; What is a transition cost?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; Transitioning data from S3 Standard to S3 Standard-Infrequent Access will be charged $0.01 per 1,000 requests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Is there a cost for expiration action?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; No, there is no cost for deleting objects via lifecycle.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Are there any charges for early deletion?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; Yes, S3 offers a few storage classes such as glacier deep archive, One zone IA, etc, which has a constraint of minimum storage duration. If an object residing in any such storage class is deleted before the minimum storage duration is completed then you will incur charges for early deletion. For more information please refer to the following document.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Are there any other costs involved in the S3 lifecycle?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; There are per-request ingest charges when using PUT, COPY, or lifecycle rules to move data into any S3 storage class. Consider the ingest or transition cost before moving objects into any storage class.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Can compressing the file help?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; Compressing the file would help reduce the amount of storage your data claims. But this might only be effective if the compression causes a significant difference in storage. S3 doesn't support any native capability of compressing data, one alternative would be to download the data, compress it and then re-upload it, and later delete the uncompressed data. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Is there any other option to keep the files but reduce the cost?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; You can consider transitioning your data into a different storage class that offers storage at a reduced rate. Here, If your use case is of archiving your objects such that you rarely access this data. Then you can consider S3 Glacier Instant Retrieval, S3 Glacier Flexible Retrieval, or S3 Glacier Deep Archive. Or, if you can bear the loss of data in case of any physical loss of an Availability Zone resulting from disasters then you can consider transitioning your data to S3 one zone IA which is again a cheaper alternative as compared to S3 standard storage class. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; What are S3 Glacier and S3 Glacier Deep Archive storage types?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ans:&lt;/strong&gt; The S3 Glacier Instant Retrieval, S3 Glacier Flexible Retrieval, and S3 Glacier Deep Archive storage classes are designed for low-cost data archiving. These storage classes offer the same durability and resiliency as the S3 Standard and S3 Standard-IA storage classes but at reduced rates of storage. However, do note there are retrieval charges involved with these storage classes. The S3 Glacier Flexible Retrieval and S3 Glacier Deep Archive objects are not available for real-time access. You must first restore the S3 Glacier Flexible Retrieval and S3 Glacier Deep Archive objects before you can access them. You can reduce S3 Glacier Deep Archive retrieval costs by using bulk retrieval, which returns data within 48 hours.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Also, S3 Glacier Flexible Retrieval and S3 Glacier Deep Archive come with a constraint of minimum storage duration of 90 and 180 days respectively. Hence, If your use case is to archive data for a longer duration of time, such that it will be rarely accessed then you may consider transitioning your data to S3 Glacier Instant Retrieval, S3 Glacier Flexible Retrieval, or S3 Glacier Deep Archive depending on your needs for retrieval. A comparison table and more details can be found in the below documents.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; What prefix do we need to provide?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; While specifying a prefix, you just need the prefix path and not the entire path that includes the S3 bucket name. And please make sure that the below checkboxes are marked. The following values are specified for the immediate deletion of objects present in the above-mentioned prefix.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Is there any cost for deleting the objects?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; DELETE API requests are free and you are not charged for these.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Is there a cost applied for life cycle rules?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; There is no cost in setting up the lifecycle rule. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Can we set up a rule for a specific file type?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; No, the S3 lifecycle does not support deleting specific file types. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; How to delete specific files?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; You can create a lifecycle rule and tag a specific object or specify the prefix(folder) you want the rule to apply to.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; How to create a lifecycle rule to expire only .csv files older than 45 days?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ans:&lt;/strong&gt; Implement the S3 Batch Operations feature to tag the objects. First, use the s3 inventory to get the manifest to use on the batch operation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Please be informed that there are charges for s3 inventory and s3 batch operations.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://aws.amazon.com/blogs/storage/adding-and-removing-object-tags-with-s3-batch-operations/"&gt;Adding and removing object tags with Amazon S3 Batch Operations&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-inventory.html"&gt;Amazon S3 inventory&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; When we set up the days for the expiry of an object, which value is considered created or modified?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; Please note Lifecycle actions such as expiration will consider the object created date for calculating the object lifespan after which it will delete the object depending upon the number of days specified in the field "Days after object creation field".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; What are the limitations of S3 filters?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ans:&lt;/strong&gt; At this time S3 only supports filters based on prefix and/or object tags. For example, you can create a filter for the prefix "myfolder/" with tags "Expire": "true" so only the objects under the prefix with the specified tag will be expired.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Caveats of using tags are that you must add tags to each of the objects and that adding and keeping the tags have extra charges.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Is there a cost for tagging an object?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; Yes, To PUT the tags you are charged $0.005 per 1,000 PUT requests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Is there a cost for maintaining the tags? &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; Yes, to maintain the tags you are charged $0.01 per 10,000 tags per month&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; What else do we need to consider? &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ans:&lt;/strong&gt; Please note apart from storage, you also pay for requests made against your S3 buckets and objects. Thus, you may need to take all this into account while generating an estimate of the cost that you will incur. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Ref:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/how-to-set-lifecycle-configuration-intro.html"&gt;Lifecycle configuration intro&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html"&gt;Managing your storage lifecycle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html#intro-lifecycle-rules-number-of-days"&gt;Lifecycle rules: Based on an object's age&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/blogs/storage/simplify-your-data-lifecycle-by-using-object-tags-with-amazon-s3-lifecycle/"&gt;Simplify your data lifecycle by using object tags with Amazon S3 Lifecycle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html#intro-lifecycle-rules-filter"&gt;Lifecycle rules filter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/about-aws/whats-new/2021/11/amazon-s3-lifecycle-storage-cost-savings/"&gt;Amazon s3 lifecycle storage cost savings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/about-aws/whats-new/2011/12/27/amazon-s3-announces-object-expiration/"&gt;Amazon S3 Object Expiration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/s3/pricing/"&gt;Amazon S3 pricing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/premiumsupport/knowledge-center/s3-empty-bucket-lifecycle-rule/"&gt;Empty the S3 bucket using a lifecycle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-class-intro.html#sc-glacier"&gt;Storage classes for archiving objects&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-class-intro.html#sc-compare"&gt;Comparing the Amazon S3 storage classes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/s3/storage-classes/"&gt;Amazon S3 Storage Classes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/s3/pricing/https://aws.amazon.com/premiumsupport/knowledge-center/glacier-early-delete-fees"&gt;Early delete fees&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/premiumsupport/knowledge-center/s3-lifecycle-rule-delay/"&gt;s3 lifecycle rule delay&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html#:~:text=When%20specifying%20the,object%20or%20objects"&gt;Lifecycle rules: Based on an object's age&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html"&gt;Lifecycle configuration elements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-configuration-examples.html#lifecycle-config-conceptual-ex5"&gt;Examples of S3 Lifecycle configuration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html#:~:text=Expiration%20deletes%20the%20object%2C%20and%20the%20deleted%20object%20cannot%20be%20recovered"&gt;Data recovery&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>s3</category>
    </item>
  </channel>
</rss>
