本文整理匯總了Golang中github.com/aws/aws-sdk-go/service/rds.RDS類的典型用法代碼示例。如果您正苦於以下問題:Golang RDS類的具體用法?Golang RDS怎麽用?Golang RDS使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了RDS類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: resourceAwsDbSecurityGroupRevokeRule
// Revokes the ingress rule on the db security group
func resourceAwsDbSecurityGroupRevokeRule(ingress interface{}, dbSecurityGroupName string, conn *rds.RDS) error {
ing := ingress.(map[string]interface{})
opts := rds.RevokeDBSecurityGroupIngressInput{
DBSecurityGroupName: aws.String(dbSecurityGroupName),
}
if attr, ok := ing["cidr"]; ok && attr != "" {
opts.CIDRIP = aws.String(attr.(string))
}
if attr, ok := ing["security_group_name"]; ok && attr != "" {
opts.EC2SecurityGroupName = aws.String(attr.(string))
}
if attr, ok := ing["security_group_id"]; ok && attr != "" {
opts.EC2SecurityGroupId = aws.String(attr.(string))
}
if attr, ok := ing["security_group_owner_id"]; ok && attr != "" {
opts.EC2SecurityGroupOwnerId = aws.String(attr.(string))
}
log.Printf("[DEBUG] Revoking ingress rule configuration: %#v", opts)
_, err := conn.RevokeDBSecurityGroupIngress(&opts)
if err != nil {
return fmt.Errorf("Error revoking security group ingress: %s", err)
}
return nil
}
示例2: tailLogFile
func tailLogFile(r *rds.RDS, db, name string, numLines int64, marker string) (string, string, error) {
req := &rds.DownloadDBLogFilePortionInput{
DBInstanceIdentifier: aws.String(db),
LogFileName: aws.String(name),
}
if numLines != 0 {
req.NumberOfLines = aws.Int64(numLines)
}
if marker != "" {
req.Marker = aws.String(marker)
}
var buf bytes.Buffer
var markerPtr *string
err := r.DownloadDBLogFilePortionPages(req, func(p *rds.DownloadDBLogFilePortionOutput, lastPage bool) bool {
if p.LogFileData != nil {
buf.WriteString(*p.LogFileData)
}
if lastPage {
markerPtr = p.Marker
}
return true
})
marker = ""
if markerPtr != nil {
marker = *markerPtr
}
return buf.String(), marker, err
}
示例3: getRDSInstanceById
func getRDSInstanceById(rdsc *rds.RDS, rdsid *string) (*rds.DBInstance, error) {
ddbii := &rds.DescribeDBInstancesInput{DBInstanceIdentifier: rdsid}
ddbo, err := rdsc.DescribeDBInstances(ddbii)
if err != nil {
return nil, err
}
return ddbo.DBInstances[0], nil
}
示例4: describeLogFiles
func describeLogFiles(r *rds.RDS, db string, since int64) (details []*rds.DescribeDBLogFilesDetails, err error) {
req := &rds.DescribeDBLogFilesInput{
DBInstanceIdentifier: aws.String(db),
}
if since != 0 {
req.FileLastWritten = aws.Int64(since)
}
err = r.DescribeDBLogFilesPages(req, func(p *rds.DescribeDBLogFilesOutput, lastPage bool) bool {
details = append(details, p.DescribeDBLogFiles...)
return true
})
return
}
示例5: saveTagsRDS
func saveTagsRDS(conn *rds.RDS, d *schema.ResourceData, arn string) error {
resp, err := conn.ListTagsForResource(&rds.ListTagsForResourceInput{
ResourceName: aws.String(arn),
})
if err != nil {
return fmt.Errorf("[DEBUG] Error retreiving tags for ARN: %s", arn)
}
var dt []*rds.Tag
if len(resp.TagList) > 0 {
dt = resp.TagList
}
return d.Set("tags", tagsToMapRDS(dt))
}
示例6: AddTagsToResource
func AddTagsToResource(resourceARN string, tags []*rds.Tag, rdssvc *rds.RDS, logger lager.Logger) error {
addTagsToResourceInput := &rds.AddTagsToResourceInput{
ResourceName: aws.String(resourceARN),
Tags: tags,
}
logger.Debug("add-tags-to-resource", lager.Data{"input": addTagsToResourceInput})
addTagsToResourceOutput, err := rdssvc.AddTagsToResource(addTagsToResourceInput)
if err != nil {
logger.Error("aws-rds-error", err)
if awsErr, ok := err.(awserr.Error); ok {
return errors.New(awsErr.Code() + ": " + awsErr.Message())
}
return err
}
logger.Debug("add-tags-to-resource", lager.Data{"output": addTagsToResourceOutput})
return nil
}
示例7: resourceAwsDbEventSubscriptionRetrieve
func resourceAwsDbEventSubscriptionRetrieve(
name string, rdsconn *rds.RDS) (*rds.EventSubscription, error) {
request := &rds.DescribeEventSubscriptionsInput{
SubscriptionName: aws.String(name),
}
describeResp, err := rdsconn.DescribeEventSubscriptions(request)
if err != nil {
if rdserr, ok := err.(awserr.Error); ok && rdserr.Code() == "SubscriptionNotFound" {
log.Printf("[WARN] No RDS Event Subscription by name (%s) found", name)
return nil, nil
}
return nil, fmt.Errorf("Error reading RDS Event Subscription %s: %s", name, err)
}
if len(describeResp.EventSubscriptionsList) != 1 {
return nil, fmt.Errorf("Unable to find RDS Event Subscription: %#v", describeResp.EventSubscriptionsList)
}
return describeResp.EventSubscriptionsList[0], nil
}
示例8: setTagsRDS
// setTags is a helper to set the tags for a resource. It expects the
// tags field to be named "tags"
func setTagsRDS(conn *rds.RDS, d *schema.ResourceData, arn string) error {
if d.HasChange("tags") {
oraw, nraw := d.GetChange("tags")
o := oraw.(map[string]interface{})
n := nraw.(map[string]interface{})
create, remove := diffTagsRDS(tagsFromMapRDS(o), tagsFromMapRDS(n))
// Set tags
if len(remove) > 0 {
log.Printf("[DEBUG] Removing tags: %s", remove)
k := make([]*string, len(remove), len(remove))
for i, t := range remove {
k[i] = t.Key
}
_, err := conn.RemoveTagsFromResource(&rds.RemoveTagsFromResourceInput{
ResourceName: aws.String(arn),
TagKeys: k,
})
if err != nil {
return err
}
}
if len(create) > 0 {
log.Printf("[DEBUG] Creating tags: %s", create)
_, err := conn.AddTagsToResource(&rds.AddTagsToResourceInput{
ResourceName: aws.String(arn),
Tags: create,
})
if err != nil {
return err
}
}
}
return nil
}