AWS v6.54.0 published on Friday, Sep 27, 2024 by Pulumi
aws.rds.getSnapshot
Explore with Pulumi AI
Use this data source to get information about a DB Snapshot for use when provisioning DB instances
NOTE: This data source does not apply to snapshots created on Aurora DB clusters. See the
aws.rds.ClusterSnapshot
data source for DB Cluster snapshots.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const prod = new aws.rds.Instance("prod", {
allocatedStorage: 10,
engine: "mysql",
engineVersion: "5.6.17",
instanceClass: aws.rds.InstanceType.T2_Micro,
dbName: "mydb",
username: "foo",
password: "bar",
dbSubnetGroupName: "my_database_subnet_group",
parameterGroupName: "default.mysql5.6",
});
const latestProdSnapshot = aws.rds.getSnapshotOutput({
dbInstanceIdentifier: prod.identifier,
mostRecent: true,
});
// Use the latest production snapshot to create a dev instance.
const dev = new aws.rds.Instance("dev", {
instanceClass: aws.rds.InstanceType.T2_Micro,
dbName: "mydbdev",
snapshotIdentifier: latestProdSnapshot.apply(latestProdSnapshot => latestProdSnapshot.id),
});
import pulumi
import pulumi_aws as aws
prod = aws.rds.Instance("prod",
allocated_storage=10,
engine="mysql",
engine_version="5.6.17",
instance_class=aws.rds.InstanceType.T2_MICRO,
db_name="mydb",
username="foo",
password="bar",
db_subnet_group_name="my_database_subnet_group",
parameter_group_name="default.mysql5.6")
latest_prod_snapshot = aws.rds.get_snapshot_output(db_instance_identifier=prod.identifier,
most_recent=True)
# Use the latest production snapshot to create a dev instance.
dev = aws.rds.Instance("dev",
instance_class=aws.rds.InstanceType.T2_MICRO,
db_name="mydbdev",
snapshot_identifier=latest_prod_snapshot.id)
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/rds"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
prod, err := rds.NewInstance(ctx, "prod", &rds.InstanceArgs{
AllocatedStorage: pulumi.Int(10),
Engine: pulumi.String("mysql"),
EngineVersion: pulumi.String("5.6.17"),
InstanceClass: pulumi.String(rds.InstanceType_T2_Micro),
DbName: pulumi.String("mydb"),
Username: pulumi.String("foo"),
Password: pulumi.String("bar"),
DbSubnetGroupName: pulumi.String("my_database_subnet_group"),
ParameterGroupName: pulumi.String("default.mysql5.6"),
})
if err != nil {
return err
}
latestProdSnapshot := rds.LookupSnapshotOutput(ctx, rds.GetSnapshotOutputArgs{
DbInstanceIdentifier: prod.Identifier,
MostRecent: pulumi.Bool(true),
}, nil)
// Use the latest production snapshot to create a dev instance.
_, err = rds.NewInstance(ctx, "dev", &rds.InstanceArgs{
InstanceClass: pulumi.String(rds.InstanceType_T2_Micro),
DbName: pulumi.String("mydbdev"),
SnapshotIdentifier: pulumi.String(latestProdSnapshot.ApplyT(func(latestProdSnapshot rds.GetSnapshotResult) (*string, error) {
return &latestProdSnapshot.Id, nil
}).(pulumi.StringPtrOutput)),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var prod = new Aws.Rds.Instance("prod", new()
{
AllocatedStorage = 10,
Engine = "mysql",
EngineVersion = "5.6.17",
InstanceClass = Aws.Rds.InstanceType.T2_Micro,
DbName = "mydb",
Username = "foo",
Password = "bar",
DbSubnetGroupName = "my_database_subnet_group",
ParameterGroupName = "default.mysql5.6",
});
var latestProdSnapshot = Aws.Rds.GetSnapshot.Invoke(new()
{
DbInstanceIdentifier = prod.Identifier,
MostRecent = true,
});
// Use the latest production snapshot to create a dev instance.
var dev = new Aws.Rds.Instance("dev", new()
{
InstanceClass = Aws.Rds.InstanceType.T2_Micro,
DbName = "mydbdev",
SnapshotIdentifier = latestProdSnapshot.Apply(getSnapshotResult => getSnapshotResult.Id),
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.rds.Instance;
import com.pulumi.aws.rds.InstanceArgs;
import com.pulumi.aws.rds.RdsFunctions;
import com.pulumi.aws.rds.inputs.GetSnapshotArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var prod = new Instance("prod", InstanceArgs.builder()
.allocatedStorage(10)
.engine("mysql")
.engineVersion("5.6.17")
.instanceClass("db.t2.micro")
.dbName("mydb")
.username("foo")
.password("bar")
.dbSubnetGroupName("my_database_subnet_group")
.parameterGroupName("default.mysql5.6")
.build());
final var latestProdSnapshot = RdsFunctions.getSnapshot(GetSnapshotArgs.builder()
.dbInstanceIdentifier(prod.identifier())
.mostRecent(true)
.build());
// Use the latest production snapshot to create a dev instance.
var dev = new Instance("dev", InstanceArgs.builder()
.instanceClass("db.t2.micro")
.dbName("mydbdev")
.snapshotIdentifier(latestProdSnapshot.applyValue(getSnapshotResult -> getSnapshotResult).applyValue(latestProdSnapshot -> latestProdSnapshot.applyValue(getSnapshotResult -> getSnapshotResult.id())))
.build());
}
}
resources:
prod:
type: aws:rds:Instance
properties:
allocatedStorage: 10
engine: mysql
engineVersion: 5.6.17
instanceClass: db.t2.micro
dbName: mydb
username: foo
password: bar
dbSubnetGroupName: my_database_subnet_group
parameterGroupName: default.mysql5.6
# Use the latest production snapshot to create a dev instance.
dev:
type: aws:rds:Instance
properties:
instanceClass: db.t2.micro
dbName: mydbdev
snapshotIdentifier: ${latestProdSnapshot.id}
variables:
latestProdSnapshot:
fn::invoke:
Function: aws:rds:getSnapshot
Arguments:
dbInstanceIdentifier: ${prod.identifier}
mostRecent: true
Using getSnapshot
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getSnapshot(args: GetSnapshotArgs, opts?: InvokeOptions): Promise<GetSnapshotResult>
function getSnapshotOutput(args: GetSnapshotOutputArgs, opts?: InvokeOptions): Output<GetSnapshotResult>
def get_snapshot(db_instance_identifier: Optional[str] = None,
db_snapshot_identifier: Optional[str] = None,
include_public: Optional[bool] = None,
include_shared: Optional[bool] = None,
most_recent: Optional[bool] = None,
snapshot_type: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None,
opts: Optional[InvokeOptions] = None) -> GetSnapshotResult
def get_snapshot_output(db_instance_identifier: Optional[pulumi.Input[str]] = None,
db_snapshot_identifier: Optional[pulumi.Input[str]] = None,
include_public: Optional[pulumi.Input[bool]] = None,
include_shared: Optional[pulumi.Input[bool]] = None,
most_recent: Optional[pulumi.Input[bool]] = None,
snapshot_type: Optional[pulumi.Input[str]] = None,
tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetSnapshotResult]
func LookupSnapshot(ctx *Context, args *LookupSnapshotArgs, opts ...InvokeOption) (*LookupSnapshotResult, error)
func LookupSnapshotOutput(ctx *Context, args *LookupSnapshotOutputArgs, opts ...InvokeOption) LookupSnapshotResultOutput
> Note: This function is named LookupSnapshot
in the Go SDK.
public static class GetSnapshot
{
public static Task<GetSnapshotResult> InvokeAsync(GetSnapshotArgs args, InvokeOptions? opts = null)
public static Output<GetSnapshotResult> Invoke(GetSnapshotInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetSnapshotResult> getSnapshot(GetSnapshotArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: aws:rds/getSnapshot:getSnapshot
arguments:
# arguments dictionary
The following arguments are supported:
- Db
Instance stringIdentifier - Returns the list of snapshots created by the specific db_instance
- Db
Snapshot stringIdentifier - Returns information on a specific snapshot_id.
- Include
Public bool - Set this value to true to include manual DB snapshots that are public and can be
copied or restored by any AWS account, otherwise set this value to false. The default is
false
. - bool
- Set this value to true to include shared manual DB snapshots from other
AWS accounts that this AWS account has been given permission to copy or restore, otherwise set this value to false.
The default is
false
. - Most
Recent bool - If more than one result is returned, use the most recent Snapshot.
- Snapshot
Type string - Type of snapshots to be returned. If you don't specify a SnapshotType
value, then both automated and manual snapshots are returned. Shared and public DB snapshots are not
included in the returned results by default. Possible values are,
automated
,manual
,shared
,public
andawsbackup
. - Dictionary<string, string>
- Mapping of tags, each pair of which must exactly match a pair on the desired DB snapshot.
- Db
Instance stringIdentifier - Returns the list of snapshots created by the specific db_instance
- Db
Snapshot stringIdentifier - Returns information on a specific snapshot_id.
- Include
Public bool - Set this value to true to include manual DB snapshots that are public and can be
copied or restored by any AWS account, otherwise set this value to false. The default is
false
. - bool
- Set this value to true to include shared manual DB snapshots from other
AWS accounts that this AWS account has been given permission to copy or restore, otherwise set this value to false.
The default is
false
. - Most
Recent bool - If more than one result is returned, use the most recent Snapshot.
- Snapshot
Type string - Type of snapshots to be returned. If you don't specify a SnapshotType
value, then both automated and manual snapshots are returned. Shared and public DB snapshots are not
included in the returned results by default. Possible values are,
automated
,manual
,shared
,public
andawsbackup
. - map[string]string
- Mapping of tags, each pair of which must exactly match a pair on the desired DB snapshot.
- db
Instance StringIdentifier - Returns the list of snapshots created by the specific db_instance
- db
Snapshot StringIdentifier - Returns information on a specific snapshot_id.
- include
Public Boolean - Set this value to true to include manual DB snapshots that are public and can be
copied or restored by any AWS account, otherwise set this value to false. The default is
false
. - Boolean
- Set this value to true to include shared manual DB snapshots from other
AWS accounts that this AWS account has been given permission to copy or restore, otherwise set this value to false.
The default is
false
. - most
Recent Boolean - If more than one result is returned, use the most recent Snapshot.
- snapshot
Type String - Type of snapshots to be returned. If you don't specify a SnapshotType
value, then both automated and manual snapshots are returned. Shared and public DB snapshots are not
included in the returned results by default. Possible values are,
automated
,manual
,shared
,public
andawsbackup
. - Map<String,String>
- Mapping of tags, each pair of which must exactly match a pair on the desired DB snapshot.
- db
Instance stringIdentifier - Returns the list of snapshots created by the specific db_instance
- db
Snapshot stringIdentifier - Returns information on a specific snapshot_id.
- include
Public boolean - Set this value to true to include manual DB snapshots that are public and can be
copied or restored by any AWS account, otherwise set this value to false. The default is
false
. - boolean
- Set this value to true to include shared manual DB snapshots from other
AWS accounts that this AWS account has been given permission to copy or restore, otherwise set this value to false.
The default is
false
. - most
Recent boolean - If more than one result is returned, use the most recent Snapshot.
- snapshot
Type string - Type of snapshots to be returned. If you don't specify a SnapshotType
value, then both automated and manual snapshots are returned. Shared and public DB snapshots are not
included in the returned results by default. Possible values are,
automated
,manual
,shared
,public
andawsbackup
. - {[key: string]: string}
- Mapping of tags, each pair of which must exactly match a pair on the desired DB snapshot.
- db_
instance_ stridentifier - Returns the list of snapshots created by the specific db_instance
- db_
snapshot_ stridentifier - Returns information on a specific snapshot_id.
- include_
public bool - Set this value to true to include manual DB snapshots that are public and can be
copied or restored by any AWS account, otherwise set this value to false. The default is
false
. - bool
- Set this value to true to include shared manual DB snapshots from other
AWS accounts that this AWS account has been given permission to copy or restore, otherwise set this value to false.
The default is
false
. - most_
recent bool - If more than one result is returned, use the most recent Snapshot.
- snapshot_
type str - Type of snapshots to be returned. If you don't specify a SnapshotType
value, then both automated and manual snapshots are returned. Shared and public DB snapshots are not
included in the returned results by default. Possible values are,
automated
,manual
,shared
,public
andawsbackup
. - Mapping[str, str]
- Mapping of tags, each pair of which must exactly match a pair on the desired DB snapshot.
- db
Instance StringIdentifier - Returns the list of snapshots created by the specific db_instance
- db
Snapshot StringIdentifier - Returns information on a specific snapshot_id.
- include
Public Boolean - Set this value to true to include manual DB snapshots that are public and can be
copied or restored by any AWS account, otherwise set this value to false. The default is
false
. - Boolean
- Set this value to true to include shared manual DB snapshots from other
AWS accounts that this AWS account has been given permission to copy or restore, otherwise set this value to false.
The default is
false
. - most
Recent Boolean - If more than one result is returned, use the most recent Snapshot.
- snapshot
Type String - Type of snapshots to be returned. If you don't specify a SnapshotType
value, then both automated and manual snapshots are returned. Shared and public DB snapshots are not
included in the returned results by default. Possible values are,
automated
,manual
,shared
,public
andawsbackup
. - Map<String>
- Mapping of tags, each pair of which must exactly match a pair on the desired DB snapshot.
getSnapshot Result
The following output properties are available:
- Allocated
Storage int - Allocated storage size in gigabytes (GB).
- Availability
Zone string - Name of the Availability Zone the DB instance was located in at the time of the DB snapshot.
- Db
Snapshot stringArn - ARN for the DB snapshot.
- Encrypted bool
- Whether the DB snapshot is encrypted.
- Engine string
- Name of the database engine.
- Engine
Version string - Version of the database engine.
- Id string
- The provider-assigned unique ID for this managed resource.
- Iops int
- Provisioned IOPS (I/O operations per second) value of the DB instance at the time of the snapshot.
- Kms
Key stringId - ARN for the KMS encryption key.
- License
Model string - License model information for the restored DB instance.
- Option
Group stringName - Provides the option group name for the DB snapshot.
- Original
Snapshot stringCreate Time - Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Doesn't change when the snapshot is copied.
- Port int
- Snapshot
Create stringTime - Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Changes for the copy when the snapshot is copied.
- Source
Db stringSnapshot Identifier - DB snapshot ARN that the DB snapshot was copied from. It only has value in case of cross customer or cross region copy.
- Source
Region string - Region that the DB snapshot was created in or copied from.
- Status string
- Status of this DB snapshot.
- Storage
Type string - Storage type associated with DB snapshot.
- Dictionary<string, string>
- Vpc
Id string - ID of the VPC associated with the DB snapshot.
- Db
Instance stringIdentifier - Db
Snapshot stringIdentifier - Include
Public bool - bool
- Most
Recent bool - Snapshot
Type string
- Allocated
Storage int - Allocated storage size in gigabytes (GB).
- Availability
Zone string - Name of the Availability Zone the DB instance was located in at the time of the DB snapshot.
- Db
Snapshot stringArn - ARN for the DB snapshot.
- Encrypted bool
- Whether the DB snapshot is encrypted.
- Engine string
- Name of the database engine.
- Engine
Version string - Version of the database engine.
- Id string
- The provider-assigned unique ID for this managed resource.
- Iops int
- Provisioned IOPS (I/O operations per second) value of the DB instance at the time of the snapshot.
- Kms
Key stringId - ARN for the KMS encryption key.
- License
Model string - License model information for the restored DB instance.
- Option
Group stringName - Provides the option group name for the DB snapshot.
- Original
Snapshot stringCreate Time - Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Doesn't change when the snapshot is copied.
- Port int
- Snapshot
Create stringTime - Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Changes for the copy when the snapshot is copied.
- Source
Db stringSnapshot Identifier - DB snapshot ARN that the DB snapshot was copied from. It only has value in case of cross customer or cross region copy.
- Source
Region string - Region that the DB snapshot was created in or copied from.
- Status string
- Status of this DB snapshot.
- Storage
Type string - Storage type associated with DB snapshot.
- map[string]string
- Vpc
Id string - ID of the VPC associated with the DB snapshot.
- Db
Instance stringIdentifier - Db
Snapshot stringIdentifier - Include
Public bool - bool
- Most
Recent bool - Snapshot
Type string
- allocated
Storage Integer - Allocated storage size in gigabytes (GB).
- availability
Zone String - Name of the Availability Zone the DB instance was located in at the time of the DB snapshot.
- db
Snapshot StringArn - ARN for the DB snapshot.
- encrypted Boolean
- Whether the DB snapshot is encrypted.
- engine String
- Name of the database engine.
- engine
Version String - Version of the database engine.
- id String
- The provider-assigned unique ID for this managed resource.
- iops Integer
- Provisioned IOPS (I/O operations per second) value of the DB instance at the time of the snapshot.
- kms
Key StringId - ARN for the KMS encryption key.
- license
Model String - License model information for the restored DB instance.
- option
Group StringName - Provides the option group name for the DB snapshot.
- original
Snapshot StringCreate Time - Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Doesn't change when the snapshot is copied.
- port Integer
- snapshot
Create StringTime - Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Changes for the copy when the snapshot is copied.
- source
Db StringSnapshot Identifier - DB snapshot ARN that the DB snapshot was copied from. It only has value in case of cross customer or cross region copy.
- source
Region String - Region that the DB snapshot was created in or copied from.
- status String
- Status of this DB snapshot.
- storage
Type String - Storage type associated with DB snapshot.
- Map<String,String>
- vpc
Id String - ID of the VPC associated with the DB snapshot.
- db
Instance StringIdentifier - db
Snapshot StringIdentifier - include
Public Boolean - Boolean
- most
Recent Boolean - snapshot
Type String
- allocated
Storage number - Allocated storage size in gigabytes (GB).
- availability
Zone string - Name of the Availability Zone the DB instance was located in at the time of the DB snapshot.
- db
Snapshot stringArn - ARN for the DB snapshot.
- encrypted boolean
- Whether the DB snapshot is encrypted.
- engine string
- Name of the database engine.
- engine
Version string - Version of the database engine.
- id string
- The provider-assigned unique ID for this managed resource.
- iops number
- Provisioned IOPS (I/O operations per second) value of the DB instance at the time of the snapshot.
- kms
Key stringId - ARN for the KMS encryption key.
- license
Model string - License model information for the restored DB instance.
- option
Group stringName - Provides the option group name for the DB snapshot.
- original
Snapshot stringCreate Time - Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Doesn't change when the snapshot is copied.
- port number
- snapshot
Create stringTime - Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Changes for the copy when the snapshot is copied.
- source
Db stringSnapshot Identifier - DB snapshot ARN that the DB snapshot was copied from. It only has value in case of cross customer or cross region copy.
- source
Region string - Region that the DB snapshot was created in or copied from.
- status string
- Status of this DB snapshot.
- storage
Type string - Storage type associated with DB snapshot.
- {[key: string]: string}
- vpc
Id string - ID of the VPC associated with the DB snapshot.
- db
Instance stringIdentifier - db
Snapshot stringIdentifier - include
Public boolean - boolean
- most
Recent boolean - snapshot
Type string
- allocated_
storage int - Allocated storage size in gigabytes (GB).
- availability_
zone str - Name of the Availability Zone the DB instance was located in at the time of the DB snapshot.
- db_
snapshot_ strarn - ARN for the DB snapshot.
- encrypted bool
- Whether the DB snapshot is encrypted.
- engine str
- Name of the database engine.
- engine_
version str - Version of the database engine.
- id str
- The provider-assigned unique ID for this managed resource.
- iops int
- Provisioned IOPS (I/O operations per second) value of the DB instance at the time of the snapshot.
- kms_
key_ strid - ARN for the KMS encryption key.
- license_
model str - License model information for the restored DB instance.
- option_
group_ strname - Provides the option group name for the DB snapshot.
- original_
snapshot_ strcreate_ time - Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Doesn't change when the snapshot is copied.
- port int
- snapshot_
create_ strtime - Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Changes for the copy when the snapshot is copied.
- source_
db_ strsnapshot_ identifier - DB snapshot ARN that the DB snapshot was copied from. It only has value in case of cross customer or cross region copy.
- source_
region str - Region that the DB snapshot was created in or copied from.
- status str
- Status of this DB snapshot.
- storage_
type str - Storage type associated with DB snapshot.
- Mapping[str, str]
- vpc_
id str - ID of the VPC associated with the DB snapshot.
- db_
instance_ stridentifier - db_
snapshot_ stridentifier - include_
public bool - bool
- most_
recent bool - snapshot_
type str
- allocated
Storage Number - Allocated storage size in gigabytes (GB).
- availability
Zone String - Name of the Availability Zone the DB instance was located in at the time of the DB snapshot.
- db
Snapshot StringArn - ARN for the DB snapshot.
- encrypted Boolean
- Whether the DB snapshot is encrypted.
- engine String
- Name of the database engine.
- engine
Version String - Version of the database engine.
- id String
- The provider-assigned unique ID for this managed resource.
- iops Number
- Provisioned IOPS (I/O operations per second) value of the DB instance at the time of the snapshot.
- kms
Key StringId - ARN for the KMS encryption key.
- license
Model String - License model information for the restored DB instance.
- option
Group StringName - Provides the option group name for the DB snapshot.
- original
Snapshot StringCreate Time - Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Doesn't change when the snapshot is copied.
- port Number
- snapshot
Create StringTime - Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Changes for the copy when the snapshot is copied.
- source
Db StringSnapshot Identifier - DB snapshot ARN that the DB snapshot was copied from. It only has value in case of cross customer or cross region copy.
- source
Region String - Region that the DB snapshot was created in or copied from.
- status String
- Status of this DB snapshot.
- storage
Type String - Storage type associated with DB snapshot.
- Map<String>
- vpc
Id String - ID of the VPC associated with the DB snapshot.
- db
Instance StringIdentifier - db
Snapshot StringIdentifier - include
Public Boolean - Boolean
- most
Recent Boolean - snapshot
Type String
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
aws
Terraform Provider.