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

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

问题描述

我在AWS RDS上有2个数据库,其中一个数据库用于stage,一个数据库用于production,涉及2个账户.我试图每x天将production中的数据复制到stage.我的计划是在production中创建最新的自动备份快照的副本,并将其共享到stage帐户,然后再使用production中的共享快照在stage中创建数据库.一切正常,直到遇到了我认为是错误的错误,但很容易就是我犯了一个错误.

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

...我明白了...

... I get this...

{
    "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

...或者这个...

... or this...

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

...我明白了...

... I get this...

{
    "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天全站免登陆