at91sam3s.h_如何使用s3生命周期管理云形成降低sam工件存储的成本

at91sam3s.h

One subtle thing that you do when working with AWS SAM is that you upload the Lambda deployment packages (artifacts) to a staging bucket where Lambda service retrieve these packages. After the artifacts were retrieved by AWS Lambda from S3, those packages often stay in the staging bucket and may build up over time especially for large projects with tons of Lambda functions. This often results in a slow and steady increase in S3 bills over time.

使用AWS SAM时要做的一件微妙的事情是,将Lambda部署程序包(工件)上载到暂存存储区,Lambda服务在其中从中检索这些程序包。 AWS Lambda从S3检索工件后,这些软件包通常留在登台存储桶中,并且可能随着时间的推移而堆积,特别是对于具有大量Lambda功能的大型项目。 随着时间的流逝,这通常会导致S3票据缓慢而稳定地增加。

In this article, we will explore what are the common techniques available to reduce the cost generated by the build-up of SAM deployment artifacts.

在本文中,我们将探讨可用于降低SAM部署工件堆积产生的成本的常见技术。

选项1:为开发人员环境工件添加1天有效期规则 (Option 1: Add a 1-day Expiry Rule for Dev Environment Artifacts)

Deployment artifacts for development environments are basically non-valuable to an organization, it doesn’t allow developers to extract useful debugging information out of them except cases where you really need to inspect the packages.

开发环境的部署工件基本上对组织没有价值,除非您确实需要检查软件包,否则开发人员不允许从其中提取有用的调试信息。

To help your organization reduce the cost spent on artifact storage, you can configure your development artifact storage for the S3 bucket to implement an object lifecycle management rule that will expire any build that is older than one day. You can use the following Cloud Formation template to achieve this:

为了帮助您的组织减少花费在构件存储上的成本,您可以为S3存储桶配置开发构件存储,以实施对象生命周期管理规则,该规则将使任何早于一天的构建都过期。 您可以使用以下云形成模板来实现此目的:

Cloud Formation template for the management of SAM deployment artifacts on DEV S3 using object life cycle management.
云形成模板,用于使用对象生命周期管理在DEV S3上管理SAM部署工件。

You can release this template by either:

您可以通过以下任一方式释放此模板:

  1. Using guided deployment by executing the release script from this link. It will request for the environment name (DEV, UAT, and PROD) & an AWS CLI profile name.

    通过执行此链接中的发行脚本来使用引导式部署。 它将要求环境名称 (DEV,UAT和PROD)和AWS CLI配置文件名称

  2. The release script from my Github page is designed for my code samples. If you want to write your own automation scripts, you can use the following commands:

    我的Github页面上的发布脚本是为我的代码示例设计的。 如果要编写自己的自动化脚本,则可以使用以下命令:

选项2:为UAT和PROD环境工件添加合理的到期日期 (Option 2: Add a Sensible Expiration Date for UAT & PROD Environment Artifacts)

UAT and PROD environment artifacts is a different discussion altogether from the DEV environment artifacts. They are often critical to understanding issues, security holes, and defects that existed in your production software.

UAT和PROD环境工件与DEV环境工件完全不同。 它们通常对于理解生产软件中存在的问题,安全漏洞和缺陷至关重要。

The likeliness of them, providing valuable insights to debugging and investigative activities are higher compared to their DEV counterparts. Given this fact, you might want to consider implementing a longer expiration date for these environments.

与DEV同行相比,它们的可能性更高,它们为调试和调查活动提供了宝贵的见解。 鉴于此事实,您可能需要考虑为这些环境实施更长的到期日期。

I won’t be able to define what is a “sensible expiration period” mean to your organizations. This is usually determined by the following criteria:

我将无法定义对您的组织意味着什么“ 明智的到期期限 ”。 通常,这取决于以下条件:

  • International laws regarding data security

    有关数据安全的国际法
  • Your country’s regulator laws regarding application data & artifacts

    您所在国家/地区有关应用程序数据和工件的监管者法律
  • Your organization’s internal policies

    您组织的内部政策

You can adjust the sample from the DEV environment by placing a value (in days format) that makes sense for your organization’s use-case to this section of the cloud formation template:

您可以通过将对组织的用例有意义的值(以天为单位)放置到云形成模板的此部分,从而从DEV环境中调整示例:

Life cycle rule for artifacts associated with applications managing bad debts in Singapore.
与在新加坡管理坏账的应用程序相关的工件的生命周期规则。

选项3:使用S3过渡规则来更新较旧工件的存储层 (Option 3: Use an S3 Transition Rule to Update Storage Tier of Older Artifacts)

Image for post

You can also implement a slowly shifting transition rule to your artifacts on the production environment by ensuring artifacts (Less frequently retrieved) get transitioned to colder tiers of S3 on a time frame that matters to your organization.

您还可以通过确保在对您的组织重要的时间范围内将工件(经常检索的次数较少)过渡到S3的较冷层,从而在生产环境中对工件实施缓慢转换的过渡规则。

You can achieve this by utilizing the Cloud Formation template below:

您可以通过使用下面的Cloud Formation模板来实现此目的:

Typical transition rule automation using S3 & cloud formation
使用S3和云形成的典型过渡规则自动化

The sample above applies the following rules to save cost on S3 storage:

上面的示例应用以下规则来节省S3存储上的成本:

  • It shifts warm artifacts (aged less than one year) to S3 Standard IA tier after a year.

    一年后,它将温暖的工件(不到一年)转移到S3 Standard IA层。
  • It shifts not-so-warm (aged 3 years and below) artifacts to S3 Glacier after three years.

    三年后,它将不太温暖(3岁及以下)的文物转移到S3 Glacier。
  • It deletes objects after seven years of existence in the storage

    它会在存储中存在七年后删除对象

结语 (Wrapping Up)

SAM artifacts stored in S3 buckets can pile up over a good amount of time and it would be wise to implement a smart strategy to manage these artifacts. This article showcased how S3 object life cycle management and transition rules could help organizations in reducing cost generated by storing serverless application artifacts.

存储在S3存储桶中的SAM工件可能会在很长一段时间内堆积起来,因此明智的做法是实施智能策略来管理这些工件。 本文展示了S3对象生命周期管理和转换规则如何帮助组织降低通过存储无服务器应用程序工件而产生的成本。

  • Use one-day expiration of DEV artifacts

    使用DEV工件的一日有效期
  • Use a sensible expiration date for PROD artifacts which depends on your organization’s use case.

    对PROD工件使用合理的到期日期,具体取决于您组织的用例。
  • Sensible artifact expiration dates vary between organizations and countries. State laws may affect the values that you may use for this implementation.

    明智的工件过期日期因组织和国家/地区而异。 州法律可能会影响您可以用于此实现的值。
  • You can implement a set of S3 object life cycle transition rules to slowly move less-frequent accessed artifacts to colder tiers.

    您可以实现一组S3对象生命周期过渡规则,以将不常访问的工件缓慢移动到较冷的层。

You can also access the templates for these implementations using this Github repository.

您还可以使用此Github存储库访问这些实现的模板。

相关连结 (Relevant Links)

Originally published at https://www.pogsdotnet.com on August 24, 2020.

最初于 2020年8月24日 https://www.pogsdotnet.com 发布

翻译自: https://itnext.io/how-to-reduce-cost-of-sam-artifact-storage-using-s3-lifecyle-management-cloud-formation-4e18ef0cab1b

at91sam3s.h

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值