如何通过 id 获取最新的共享 AWS RDS 快照? [英] How to get the most recent shared AWS RDS snapshot by id?

查看:33
本文介绍了如何通过 id 获取最新的共享 AWS RDS 快照?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 AWS RDS 上有 2 个数据库,一个用于 stage,一个用于 production,跨越 2 个账户.我正在尝试每 x 天将 production 中的数据复制到 stage .我的计划是在 production 中复制最新的自动备份快照,并在 stage 中创建数据库之前将其共享到 stage 帐户使用来自 production 的共享快照.一切都很顺利,直到我遇到了我认为是错误的错误,但很可能是我犯了错误.

I have 2 databases on AWS RDS, one for stage and one for production across 2 accounts. I am trying to copy the data in production to stage every x days. My plan was to make a copy of the most recent automatic backup snapshot in production and share it to the stage account before creating the database in stage using the shared snapshot from production. Everything was going right until I ran into what I believe is a bug but it could easily be that I made a mistake.

当我尝试使用 data "aws_db_snapshot" 在 Terraform 中获取 ID 为 abcd 的最新共享快照时,我没有得到任何结果.

When I tried to get the most recent, shared, snapshot with an id of abcd in Terraform with data "aws_db_snapshot", I got no results.

data "aws_db_snapshot" "latest_prod_snapshot" {
  db_instance_identifier = "abcd"
  snapshot_type          = "shared"
  include_shared         = "true"
  most_recent            = "true"
}

然后我决定试用 AWS CLI.当我运行这个...

Then I decided to try out AWS CLI. When I run this...

aws rds describe-db-snapshots --snapshot-type shared --include-shared

...我明白了...

{
    "DBSnapshots": [
        {
            "MasterUsername": "root", 
            "LicenseModel": "general-public-license", 
            "InstanceCreateTime": "2018-01-13T00:00:00.000Z", 
            "Engine": "mysql", 
            "VpcId": "vpc-0000000000000000", 
            "SourceRegion": "us-east-1", 
            "AllocatedStorage": 20, 
            "Status": "available", 
            "PercentProgress": 100, 
            "SourceDBSnapshotIdentifier": "arn:aws:rds:us-east-1:000000000000:snapshot:rds:abcd-2020-01-13-00-00", 
            "DBSnapshotIdentifier": "arn:aws:rds:us-east-1:000000000000:snapshot:rds:abcd-2020-01-13-00-00", 
            "DBSnapshotArn": "arn:aws:rds:us-east-1:000000000000:snapshot:rds:abcd-2020-01-13-00-00", 
            "EngineVersion": "5.6.41", 
            "ProcessorFeatures": [], 
            "OptionGroupName": "default:mysql-5-6", 
            "SnapshotCreateTime": "2020-01-13T00:00:00.000Z", 
            "AvailabilityZone": "us-east-1b", 
            "StorageType": "gp2", 
            "Encrypted": false, 
            "IAMDatabaseAuthenticationEnabled": false, 
            "DbiResourceId": "db-AAAAAAAAAAAAAAAAAAAAAAAAA", 
            "SnapshotType": "shared", 
            "Port": 3306, 
            "DBInstanceIdentifier": "abcd"
        }
    ]
}

...这是我所期望的.查看响应,我希望数据库实例 id 是 abcd 但是当我运行它时......

... which is what I expected. Looking at the response, I would expect the db instance id to be abcd but when I run this...

aws rds describe-db-snapshots --snapshot-type shared --include-shared --db-instance-identifier abcd

...或者这个...

aws rds describe-db-snapshots --snapshot-type shared --include-shared --filters Name=db-instance-id,Values=abcd

...我明白了...

{
    "DBSnapshots": []
}

...这不是我所期望的.这是一个错误还是我做错了什么?我查看了他们的文档,但我可能遗漏了一些东西.

... which is not what I would have expected. Is this a bug or am I doing something wrong? I looked through their documentation but I may have missed something.

推荐答案

在我们等待 AWS 解决此问题的同时.以下是您可以做的一些解决方法:

While we wait for AWS to fix this. Here are some things you can do as workaround:

  1. stage 帐户中复制共享快照并使用副本而不是共享.
  2. 在 Terraform 中,回滚到较旧的提供程序版本.
  1. In the stage account copy the shared snapshot and use the copy instead of the shared.
  2. In Terraform, rollback to an older provider version.

2.27 适合我

provider "aws" {
  version                 = "2.27.0"
}

这篇关于如何通过 id 获取最新的共享 AWS RDS 快照?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆