| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075 |
- // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
- package rds_test
- import (
- "fmt"
- "strings"
- "time"
- "github.com/aws/aws-sdk-go/aws"
- "github.com/aws/aws-sdk-go/aws/awserr"
- "github.com/aws/aws-sdk-go/aws/session"
- "github.com/aws/aws-sdk-go/service/rds"
- )
- var _ time.Duration
- var _ strings.Reader
- var _ aws.Config
- func parseTime(layout, value string) *time.Time {
- t, err := time.Parse(layout, value)
- if err != nil {
- panic(err)
- }
- return &t
- }
- // To add a source identifier to an event notification subscription
- //
- // This example add a source identifier to an event notification subscription.
- func ExampleRDS_AddSourceIdentifierToSubscription_shared00() {
- svc := rds.New(session.New())
- input := &rds.AddSourceIdentifierToSubscriptionInput{
- SourceIdentifier: aws.String("mymysqlinstance"),
- SubscriptionName: aws.String("mymysqleventsubscription"),
- }
- result, err := svc.AddSourceIdentifierToSubscription(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeSubscriptionNotFoundFault:
- fmt.Println(rds.ErrCodeSubscriptionNotFoundFault, aerr.Error())
- case rds.ErrCodeSourceNotFoundFault:
- fmt.Println(rds.ErrCodeSourceNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To add tags to a resource
- //
- // This example adds a tag to an option group.
- func ExampleRDS_AddTagsToResource_shared00() {
- svc := rds.New(session.New())
- input := &rds.AddTagsToResourceInput{
- ResourceName: aws.String("arn:aws:rds:us-east-1:992648334831:og:mymysqloptiongroup"),
- Tags: []*rds.Tag{
- {
- Key: aws.String("Staging"),
- Value: aws.String("LocationDB"),
- },
- },
- }
- result, err := svc.AddTagsToResource(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBInstanceNotFoundFault:
- fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error())
- case rds.ErrCodeDBSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error())
- case rds.ErrCodeDBClusterNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To apply a pending maintenance action
- //
- // This example immediately applies a pending system update to a DB instance.
- func ExampleRDS_ApplyPendingMaintenanceAction_shared00() {
- svc := rds.New(session.New())
- input := &rds.ApplyPendingMaintenanceActionInput{
- ApplyAction: aws.String("system-update"),
- OptInType: aws.String("immediate"),
- ResourceIdentifier: aws.String("arn:aws:rds:us-east-1:992648334831:db:mymysqlinstance"),
- }
- result, err := svc.ApplyPendingMaintenanceAction(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeResourceNotFoundFault:
- fmt.Println(rds.ErrCodeResourceNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidDBClusterStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error())
- case rds.ErrCodeInvalidDBInstanceStateFault:
- fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To authorize DB security group integress
- //
- // This example authorizes access to the specified security group by the specified CIDR
- // block.
- func ExampleRDS_AuthorizeDBSecurityGroupIngress_shared00() {
- svc := rds.New(session.New())
- input := &rds.AuthorizeDBSecurityGroupIngressInput{
- CIDRIP: aws.String("203.0.113.5/32"),
- DBSecurityGroupName: aws.String("mydbsecuritygroup"),
- }
- result, err := svc.AuthorizeDBSecurityGroupIngress(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBSecurityGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidDBSecurityGroupStateFault:
- fmt.Println(rds.ErrCodeInvalidDBSecurityGroupStateFault, aerr.Error())
- case rds.ErrCodeAuthorizationAlreadyExistsFault:
- fmt.Println(rds.ErrCodeAuthorizationAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeAuthorizationQuotaExceededFault:
- fmt.Println(rds.ErrCodeAuthorizationQuotaExceededFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To copy a DB cluster parameter group
- //
- // This example copies a DB cluster parameter group.
- func ExampleRDS_CopyDBClusterParameterGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.CopyDBClusterParameterGroupInput{
- SourceDBClusterParameterGroupIdentifier: aws.String("mydbclusterparametergroup"),
- TargetDBClusterParameterGroupDescription: aws.String("My DB cluster parameter group copy"),
- TargetDBClusterParameterGroupIdentifier: aws.String("mydbclusterparametergroup-copy"),
- }
- result, err := svc.CopyDBClusterParameterGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDBParameterGroupQuotaExceededFault:
- fmt.Println(rds.ErrCodeDBParameterGroupQuotaExceededFault, aerr.Error())
- case rds.ErrCodeDBParameterGroupAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBParameterGroupAlreadyExistsFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To copy a DB cluster snapshot
- //
- // The following example copies an automated snapshot of a DB cluster to a new DB cluster
- // snapshot.
- func ExampleRDS_CopyDBClusterSnapshot_shared00() {
- svc := rds.New(session.New())
- input := &rds.CopyDBClusterSnapshotInput{
- SourceDBClusterSnapshotIdentifier: aws.String("rds:sample-cluster-2016-09-14-10-38"),
- TargetDBClusterSnapshotIdentifier: aws.String("cluster-snapshot-copy-1"),
- }
- result, err := svc.CopyDBClusterSnapshot(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBClusterSnapshotAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBClusterSnapshotAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeDBClusterSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterSnapshotNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidDBClusterStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error())
- case rds.ErrCodeInvalidDBClusterSnapshotStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterSnapshotStateFault, aerr.Error())
- case rds.ErrCodeSnapshotQuotaExceededFault:
- fmt.Println(rds.ErrCodeSnapshotQuotaExceededFault, aerr.Error())
- case rds.ErrCodeKMSKeyNotAccessibleFault:
- fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To copy a DB parameter group
- //
- // This example copies a DB parameter group.
- func ExampleRDS_CopyDBParameterGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.CopyDBParameterGroupInput{
- SourceDBParameterGroupIdentifier: aws.String("mymysqlparametergroup"),
- TargetDBParameterGroupDescription: aws.String("My MySQL parameter group copy"),
- TargetDBParameterGroupIdentifier: aws.String("mymysqlparametergroup-copy"),
- }
- result, err := svc.CopyDBParameterGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDBParameterGroupAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBParameterGroupAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeDBParameterGroupQuotaExceededFault:
- fmt.Println(rds.ErrCodeDBParameterGroupQuotaExceededFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To copy a DB snapshot
- //
- // This example copies a DB snapshot.
- func ExampleRDS_CopyDBSnapshot_shared00() {
- svc := rds.New(session.New())
- input := &rds.CopyDBSnapshotInput{
- SourceDBSnapshotIdentifier: aws.String("mydbsnapshot"),
- TargetDBSnapshotIdentifier: aws.String("mydbsnapshot-copy"),
- }
- result, err := svc.CopyDBSnapshot(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBSnapshotAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBSnapshotAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeDBSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidDBSnapshotStateFault:
- fmt.Println(rds.ErrCodeInvalidDBSnapshotStateFault, aerr.Error())
- case rds.ErrCodeSnapshotQuotaExceededFault:
- fmt.Println(rds.ErrCodeSnapshotQuotaExceededFault, aerr.Error())
- case rds.ErrCodeKMSKeyNotAccessibleFault:
- fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To copy an option group
- //
- // This example copies an option group.
- func ExampleRDS_CopyOptionGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.CopyOptionGroupInput{
- SourceOptionGroupIdentifier: aws.String("mymysqloptiongroup"),
- TargetOptionGroupDescription: aws.String("My MySQL option group copy"),
- TargetOptionGroupIdentifier: aws.String("mymysqloptiongroup-copy"),
- }
- result, err := svc.CopyOptionGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeOptionGroupAlreadyExistsFault:
- fmt.Println(rds.ErrCodeOptionGroupAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeOptionGroupNotFoundFault:
- fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeOptionGroupQuotaExceededFault:
- fmt.Println(rds.ErrCodeOptionGroupQuotaExceededFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To create a DB cluster
- //
- // This example creates a DB cluster.
- func ExampleRDS_CreateDBCluster_shared00() {
- svc := rds.New(session.New())
- input := &rds.CreateDBClusterInput{
- AvailabilityZones: []*string{
- aws.String("us-east-1a"),
- },
- BackupRetentionPeriod: aws.Int64(1),
- DBClusterIdentifier: aws.String("mydbcluster"),
- DBClusterParameterGroupName: aws.String("mydbclusterparametergroup"),
- DatabaseName: aws.String("myauroradb"),
- Engine: aws.String("aurora"),
- EngineVersion: aws.String("5.6.10a"),
- MasterUserPassword: aws.String("mypassword"),
- MasterUsername: aws.String("myuser"),
- Port: aws.Int64(3306),
- StorageEncrypted: aws.Bool(true),
- }
- result, err := svc.CreateDBCluster(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBClusterAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBClusterAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeInsufficientStorageClusterCapacityFault:
- fmt.Println(rds.ErrCodeInsufficientStorageClusterCapacityFault, aerr.Error())
- case rds.ErrCodeDBClusterQuotaExceededFault:
- fmt.Println(rds.ErrCodeDBClusterQuotaExceededFault, aerr.Error())
- case rds.ErrCodeStorageQuotaExceededFault:
- fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidVPCNetworkStateFault:
- fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error())
- case rds.ErrCodeInvalidDBClusterStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error())
- case rds.ErrCodeInvalidDBSubnetGroupStateFault:
- fmt.Println(rds.ErrCodeInvalidDBSubnetGroupStateFault, aerr.Error())
- case rds.ErrCodeInvalidSubnet:
- fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error())
- case rds.ErrCodeInvalidDBInstanceStateFault:
- fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error())
- case rds.ErrCodeDBClusterParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterParameterGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeKMSKeyNotAccessibleFault:
- fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, aerr.Error())
- case rds.ErrCodeDBClusterNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error())
- case rds.ErrCodeDBInstanceNotFoundFault:
- fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs:
- fmt.Println(rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs, aerr.Error())
- case rds.ErrCodeGlobalClusterNotFoundFault:
- fmt.Println(rds.ErrCodeGlobalClusterNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidGlobalClusterStateFault:
- fmt.Println(rds.ErrCodeInvalidGlobalClusterStateFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To create a DB cluster parameter group
- //
- // This example creates a DB cluster parameter group.
- func ExampleRDS_CreateDBClusterParameterGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.CreateDBClusterParameterGroupInput{
- DBClusterParameterGroupName: aws.String("mydbclusterparametergroup"),
- DBParameterGroupFamily: aws.String("aurora5.6"),
- Description: aws.String("My DB cluster parameter group"),
- }
- result, err := svc.CreateDBClusterParameterGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBParameterGroupQuotaExceededFault:
- fmt.Println(rds.ErrCodeDBParameterGroupQuotaExceededFault, aerr.Error())
- case rds.ErrCodeDBParameterGroupAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBParameterGroupAlreadyExistsFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To create a DB cluster snapshot
- //
- // This example creates a DB cluster snapshot.
- func ExampleRDS_CreateDBClusterSnapshot_shared00() {
- svc := rds.New(session.New())
- input := &rds.CreateDBClusterSnapshotInput{
- DBClusterIdentifier: aws.String("mydbcluster"),
- DBClusterSnapshotIdentifier: aws.String("mydbclustersnapshot"),
- }
- result, err := svc.CreateDBClusterSnapshot(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBClusterSnapshotAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBClusterSnapshotAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeInvalidDBClusterStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error())
- case rds.ErrCodeDBClusterNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error())
- case rds.ErrCodeSnapshotQuotaExceededFault:
- fmt.Println(rds.ErrCodeSnapshotQuotaExceededFault, aerr.Error())
- case rds.ErrCodeInvalidDBClusterSnapshotStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterSnapshotStateFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To create a DB instance.
- //
- // This example creates a DB instance.
- func ExampleRDS_CreateDBInstance_shared00() {
- svc := rds.New(session.New())
- input := &rds.CreateDBInstanceInput{
- AllocatedStorage: aws.Int64(5),
- DBInstanceClass: aws.String("db.t2.micro"),
- DBInstanceIdentifier: aws.String("mymysqlinstance"),
- Engine: aws.String("MySQL"),
- MasterUserPassword: aws.String("MyPassword"),
- MasterUsername: aws.String("MyUser"),
- }
- result, err := svc.CreateDBInstance(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBInstanceAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBInstanceAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeInsufficientDBInstanceCapacityFault:
- fmt.Println(rds.ErrCodeInsufficientDBInstanceCapacityFault, aerr.Error())
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDBSecurityGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeInstanceQuotaExceededFault:
- fmt.Println(rds.ErrCodeInstanceQuotaExceededFault, aerr.Error())
- case rds.ErrCodeStorageQuotaExceededFault:
- fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs:
- fmt.Println(rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs, aerr.Error())
- case rds.ErrCodeInvalidDBClusterStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error())
- case rds.ErrCodeInvalidSubnet:
- fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error())
- case rds.ErrCodeInvalidVPCNetworkStateFault:
- fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error())
- case rds.ErrCodeProvisionedIopsNotAvailableInAZFault:
- fmt.Println(rds.ErrCodeProvisionedIopsNotAvailableInAZFault, aerr.Error())
- case rds.ErrCodeOptionGroupNotFoundFault:
- fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDBClusterNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error())
- case rds.ErrCodeStorageTypeNotSupportedFault:
- fmt.Println(rds.ErrCodeStorageTypeNotSupportedFault, aerr.Error())
- case rds.ErrCodeAuthorizationNotFoundFault:
- fmt.Println(rds.ErrCodeAuthorizationNotFoundFault, aerr.Error())
- case rds.ErrCodeKMSKeyNotAccessibleFault:
- fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, aerr.Error())
- case rds.ErrCodeDomainNotFoundFault:
- fmt.Println(rds.ErrCodeDomainNotFoundFault, aerr.Error())
- case rds.ErrCodeBackupPolicyNotFoundFault:
- fmt.Println(rds.ErrCodeBackupPolicyNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To create a DB instance read replica.
- //
- // This example creates a DB instance read replica.
- func ExampleRDS_CreateDBInstanceReadReplica_shared00() {
- svc := rds.New(session.New())
- input := &rds.CreateDBInstanceReadReplicaInput{
- AvailabilityZone: aws.String("us-east-1a"),
- CopyTagsToSnapshot: aws.Bool(true),
- DBInstanceClass: aws.String("db.t2.micro"),
- DBInstanceIdentifier: aws.String("mydbreadreplica"),
- PubliclyAccessible: aws.Bool(true),
- SourceDBInstanceIdentifier: aws.String("mymysqlinstance"),
- StorageType: aws.String("gp2"),
- Tags: []*rds.Tag{
- {
- Key: aws.String("mydbreadreplicakey"),
- Value: aws.String("mydbreadreplicavalue"),
- },
- },
- }
- result, err := svc.CreateDBInstanceReadReplica(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBInstanceAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBInstanceAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeInsufficientDBInstanceCapacityFault:
- fmt.Println(rds.ErrCodeInsufficientDBInstanceCapacityFault, aerr.Error())
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDBSecurityGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeInstanceQuotaExceededFault:
- fmt.Println(rds.ErrCodeInstanceQuotaExceededFault, aerr.Error())
- case rds.ErrCodeStorageQuotaExceededFault:
- fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error())
- case rds.ErrCodeDBInstanceNotFoundFault:
- fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidDBInstanceStateFault:
- fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs:
- fmt.Println(rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs, aerr.Error())
- case rds.ErrCodeInvalidSubnet:
- fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error())
- case rds.ErrCodeInvalidVPCNetworkStateFault:
- fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error())
- case rds.ErrCodeProvisionedIopsNotAvailableInAZFault:
- fmt.Println(rds.ErrCodeProvisionedIopsNotAvailableInAZFault, aerr.Error())
- case rds.ErrCodeOptionGroupNotFoundFault:
- fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupNotAllowedFault:
- fmt.Println(rds.ErrCodeDBSubnetGroupNotAllowedFault, aerr.Error())
- case rds.ErrCodeInvalidDBSubnetGroupFault:
- fmt.Println(rds.ErrCodeInvalidDBSubnetGroupFault, aerr.Error())
- case rds.ErrCodeStorageTypeNotSupportedFault:
- fmt.Println(rds.ErrCodeStorageTypeNotSupportedFault, aerr.Error())
- case rds.ErrCodeKMSKeyNotAccessibleFault:
- fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To create a DB parameter group.
- //
- // This example creates a DB parameter group.
- func ExampleRDS_CreateDBParameterGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.CreateDBParameterGroupInput{
- DBParameterGroupFamily: aws.String("mysql5.6"),
- DBParameterGroupName: aws.String("mymysqlparametergroup"),
- Description: aws.String("My MySQL parameter group"),
- }
- result, err := svc.CreateDBParameterGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBParameterGroupQuotaExceededFault:
- fmt.Println(rds.ErrCodeDBParameterGroupQuotaExceededFault, aerr.Error())
- case rds.ErrCodeDBParameterGroupAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBParameterGroupAlreadyExistsFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To create a DB security group.
- //
- // This example creates a DB security group.
- func ExampleRDS_CreateDBSecurityGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.CreateDBSecurityGroupInput{
- DBSecurityGroupDescription: aws.String("My DB security group"),
- DBSecurityGroupName: aws.String("mydbsecuritygroup"),
- }
- result, err := svc.CreateDBSecurityGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBSecurityGroupAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBSecurityGroupAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeDBSecurityGroupQuotaExceededFault:
- fmt.Println(rds.ErrCodeDBSecurityGroupQuotaExceededFault, aerr.Error())
- case rds.ErrCodeDBSecurityGroupNotSupportedFault:
- fmt.Println(rds.ErrCodeDBSecurityGroupNotSupportedFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To create a DB snapshot.
- //
- // This example creates a DB snapshot.
- func ExampleRDS_CreateDBSnapshot_shared00() {
- svc := rds.New(session.New())
- input := &rds.CreateDBSnapshotInput{
- DBInstanceIdentifier: aws.String("mymysqlinstance"),
- DBSnapshotIdentifier: aws.String("mydbsnapshot"),
- }
- result, err := svc.CreateDBSnapshot(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBSnapshotAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBSnapshotAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeInvalidDBInstanceStateFault:
- fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error())
- case rds.ErrCodeDBInstanceNotFoundFault:
- fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error())
- case rds.ErrCodeSnapshotQuotaExceededFault:
- fmt.Println(rds.ErrCodeSnapshotQuotaExceededFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To create a DB subnet group.
- //
- // This example creates a DB subnet group.
- func ExampleRDS_CreateDBSubnetGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.CreateDBSubnetGroupInput{
- DBSubnetGroupDescription: aws.String("My DB subnet group"),
- DBSubnetGroupName: aws.String("mydbsubnetgroup"),
- SubnetIds: []*string{
- aws.String("subnet-1fab8a69"),
- aws.String("subnet-d43a468c"),
- },
- }
- result, err := svc.CreateDBSubnetGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBSubnetGroupAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBSubnetGroupAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupQuotaExceededFault:
- fmt.Println(rds.ErrCodeDBSubnetGroupQuotaExceededFault, aerr.Error())
- case rds.ErrCodeDBSubnetQuotaExceededFault:
- fmt.Println(rds.ErrCodeDBSubnetQuotaExceededFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs:
- fmt.Println(rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs, aerr.Error())
- case rds.ErrCodeInvalidSubnet:
- fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To create an event notification subscription
- //
- // This example creates an event notification subscription.
- func ExampleRDS_CreateEventSubscription_shared00() {
- svc := rds.New(session.New())
- input := &rds.CreateEventSubscriptionInput{
- Enabled: aws.Bool(true),
- EventCategories: []*string{
- aws.String("availability"),
- },
- SnsTopicArn: aws.String("arn:aws:sns:us-east-1:992648334831:MyDemoSNSTopic"),
- SourceIds: []*string{
- aws.String("mymysqlinstance"),
- },
- SourceType: aws.String("db-instance"),
- SubscriptionName: aws.String("mymysqleventsubscription"),
- }
- result, err := svc.CreateEventSubscription(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeEventSubscriptionQuotaExceededFault:
- fmt.Println(rds.ErrCodeEventSubscriptionQuotaExceededFault, aerr.Error())
- case rds.ErrCodeSubscriptionAlreadyExistFault:
- fmt.Println(rds.ErrCodeSubscriptionAlreadyExistFault, aerr.Error())
- case rds.ErrCodeSNSInvalidTopicFault:
- fmt.Println(rds.ErrCodeSNSInvalidTopicFault, aerr.Error())
- case rds.ErrCodeSNSNoAuthorizationFault:
- fmt.Println(rds.ErrCodeSNSNoAuthorizationFault, aerr.Error())
- case rds.ErrCodeSNSTopicArnNotFoundFault:
- fmt.Println(rds.ErrCodeSNSTopicArnNotFoundFault, aerr.Error())
- case rds.ErrCodeSubscriptionCategoryNotFoundFault:
- fmt.Println(rds.ErrCodeSubscriptionCategoryNotFoundFault, aerr.Error())
- case rds.ErrCodeSourceNotFoundFault:
- fmt.Println(rds.ErrCodeSourceNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To create an option group
- //
- // This example creates an option group.
- func ExampleRDS_CreateOptionGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.CreateOptionGroupInput{
- EngineName: aws.String("MySQL"),
- MajorEngineVersion: aws.String("5.6"),
- OptionGroupDescription: aws.String("My MySQL 5.6 option group"),
- OptionGroupName: aws.String("mymysqloptiongroup"),
- }
- result, err := svc.CreateOptionGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeOptionGroupAlreadyExistsFault:
- fmt.Println(rds.ErrCodeOptionGroupAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeOptionGroupQuotaExceededFault:
- fmt.Println(rds.ErrCodeOptionGroupQuotaExceededFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To delete a DB cluster.
- //
- // This example deletes the specified DB cluster.
- func ExampleRDS_DeleteDBCluster_shared00() {
- svc := rds.New(session.New())
- input := &rds.DeleteDBClusterInput{
- DBClusterIdentifier: aws.String("mydbcluster"),
- SkipFinalSnapshot: aws.Bool(true),
- }
- result, err := svc.DeleteDBCluster(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBClusterNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidDBClusterStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error())
- case rds.ErrCodeDBClusterSnapshotAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBClusterSnapshotAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeSnapshotQuotaExceededFault:
- fmt.Println(rds.ErrCodeSnapshotQuotaExceededFault, aerr.Error())
- case rds.ErrCodeInvalidDBClusterSnapshotStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterSnapshotStateFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To delete a DB cluster parameter group.
- //
- // This example deletes the specified DB cluster parameter group.
- func ExampleRDS_DeleteDBClusterParameterGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.DeleteDBClusterParameterGroupInput{
- DBClusterParameterGroupName: aws.String("mydbclusterparametergroup"),
- }
- result, err := svc.DeleteDBClusterParameterGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeInvalidDBParameterGroupStateFault:
- fmt.Println(rds.ErrCodeInvalidDBParameterGroupStateFault, aerr.Error())
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To delete a DB cluster snapshot.
- //
- // This example deletes the specified DB cluster snapshot.
- func ExampleRDS_DeleteDBClusterSnapshot_shared00() {
- svc := rds.New(session.New())
- input := &rds.DeleteDBClusterSnapshotInput{
- DBClusterSnapshotIdentifier: aws.String("mydbclustersnapshot"),
- }
- result, err := svc.DeleteDBClusterSnapshot(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeInvalidDBClusterSnapshotStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterSnapshotStateFault, aerr.Error())
- case rds.ErrCodeDBClusterSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterSnapshotNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To delete a DB instance.
- //
- // This example deletes the specified DB instance.
- func ExampleRDS_DeleteDBInstance_shared00() {
- svc := rds.New(session.New())
- input := &rds.DeleteDBInstanceInput{
- DBInstanceIdentifier: aws.String("mymysqlinstance"),
- SkipFinalSnapshot: aws.Bool(true),
- }
- result, err := svc.DeleteDBInstance(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBInstanceNotFoundFault:
- fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidDBInstanceStateFault:
- fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error())
- case rds.ErrCodeDBSnapshotAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBSnapshotAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeSnapshotQuotaExceededFault:
- fmt.Println(rds.ErrCodeSnapshotQuotaExceededFault, aerr.Error())
- case rds.ErrCodeInvalidDBClusterStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error())
- case rds.ErrCodeDBInstanceAutomatedBackupQuotaExceededFault:
- fmt.Println(rds.ErrCodeDBInstanceAutomatedBackupQuotaExceededFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To delete a DB parameter group
- //
- // The following example deletes a DB parameter group.
- func ExampleRDS_DeleteDBParameterGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.DeleteDBParameterGroupInput{
- DBParameterGroupName: aws.String("mydbparamgroup3"),
- }
- result, err := svc.DeleteDBParameterGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeInvalidDBParameterGroupStateFault:
- fmt.Println(rds.ErrCodeInvalidDBParameterGroupStateFault, aerr.Error())
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To delete a DB security group
- //
- // The following example deletes a DB security group.
- func ExampleRDS_DeleteDBSecurityGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.DeleteDBSecurityGroupInput{
- DBSecurityGroupName: aws.String("mysecgroup"),
- }
- result, err := svc.DeleteDBSecurityGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeInvalidDBSecurityGroupStateFault:
- fmt.Println(rds.ErrCodeInvalidDBSecurityGroupStateFault, aerr.Error())
- case rds.ErrCodeDBSecurityGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To delete a DB cluster snapshot.
- //
- // This example deletes the specified DB snapshot.
- func ExampleRDS_DeleteDBSnapshot_shared00() {
- svc := rds.New(session.New())
- input := &rds.DeleteDBSnapshotInput{
- DBSnapshotIdentifier: aws.String("mydbsnapshot"),
- }
- result, err := svc.DeleteDBSnapshot(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeInvalidDBSnapshotStateFault:
- fmt.Println(rds.ErrCodeInvalidDBSnapshotStateFault, aerr.Error())
- case rds.ErrCodeDBSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To delete a DB subnet group.
- //
- // This example deletes the specified DB subnetgroup.
- func ExampleRDS_DeleteDBSubnetGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.DeleteDBSubnetGroupInput{
- DBSubnetGroupName: aws.String("mydbsubnetgroup"),
- }
- result, err := svc.DeleteDBSubnetGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeInvalidDBSubnetGroupStateFault:
- fmt.Println(rds.ErrCodeInvalidDBSubnetGroupStateFault, aerr.Error())
- case rds.ErrCodeInvalidDBSubnetStateFault:
- fmt.Println(rds.ErrCodeInvalidDBSubnetStateFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To delete a DB event subscription.
- //
- // This example deletes the specified DB event subscription.
- func ExampleRDS_DeleteEventSubscription_shared00() {
- svc := rds.New(session.New())
- input := &rds.DeleteEventSubscriptionInput{
- SubscriptionName: aws.String("myeventsubscription"),
- }
- result, err := svc.DeleteEventSubscription(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeSubscriptionNotFoundFault:
- fmt.Println(rds.ErrCodeSubscriptionNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidEventSubscriptionStateFault:
- fmt.Println(rds.ErrCodeInvalidEventSubscriptionStateFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To delete an option group.
- //
- // This example deletes the specified option group.
- func ExampleRDS_DeleteOptionGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.DeleteOptionGroupInput{
- OptionGroupName: aws.String("mydboptiongroup"),
- }
- result, err := svc.DeleteOptionGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeOptionGroupNotFoundFault:
- fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidOptionGroupStateFault:
- fmt.Println(rds.ErrCodeInvalidOptionGroupStateFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list account attributes
- //
- // This example lists account attributes.
- func ExampleRDS_DescribeAccountAttributes_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeAccountAttributesInput{}
- result, err := svc.DescribeAccountAttributes(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list certificates
- //
- // This example lists up to 20 certificates for the specified certificate identifier.
- func ExampleRDS_DescribeCertificates_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeCertificatesInput{
- CertificateIdentifier: aws.String("rds-ca-2015"),
- MaxRecords: aws.Int64(20),
- }
- result, err := svc.DescribeCertificates(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeCertificateNotFoundFault:
- fmt.Println(rds.ErrCodeCertificateNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list DB cluster parameter group settings
- //
- // This example lists settings for the specified DB cluster parameter group.
- func ExampleRDS_DescribeDBClusterParameterGroups_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeDBClusterParameterGroupsInput{
- DBClusterParameterGroupName: aws.String("mydbclusterparametergroup"),
- }
- result, err := svc.DescribeDBClusterParameterGroups(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list DB cluster parameters
- //
- // This example lists system parameters for the specified DB cluster parameter group.
- func ExampleRDS_DescribeDBClusterParameters_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeDBClusterParametersInput{
- DBClusterParameterGroupName: aws.String("mydbclusterparametergroup"),
- Source: aws.String("system"),
- }
- result, err := svc.DescribeDBClusterParameters(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list DB cluster snapshot attributes
- //
- // This example lists attributes for the specified DB cluster snapshot.
- func ExampleRDS_DescribeDBClusterSnapshotAttributes_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeDBClusterSnapshotAttributesInput{
- DBClusterSnapshotIdentifier: aws.String("mydbclustersnapshot"),
- }
- result, err := svc.DescribeDBClusterSnapshotAttributes(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBClusterSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterSnapshotNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list DB cluster snapshots
- //
- // This example lists settings for the specified, manually-created cluster snapshot.
- func ExampleRDS_DescribeDBClusterSnapshots_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeDBClusterSnapshotsInput{
- DBClusterSnapshotIdentifier: aws.String("mydbclustersnapshot"),
- SnapshotType: aws.String("manual"),
- }
- result, err := svc.DescribeDBClusterSnapshots(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBClusterSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterSnapshotNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list DB clusters
- //
- // This example lists settings for the specified DB cluster.
- func ExampleRDS_DescribeDBClusters_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeDBClustersInput{
- DBClusterIdentifier: aws.String("mynewdbcluster"),
- }
- result, err := svc.DescribeDBClusters(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBClusterNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list DB engine version settings
- //
- // This example lists settings for the specified DB engine version.
- func ExampleRDS_DescribeDBEngineVersions_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeDBEngineVersionsInput{
- DBParameterGroupFamily: aws.String("mysql5.6"),
- DefaultOnly: aws.Bool(true),
- Engine: aws.String("mysql"),
- EngineVersion: aws.String("5.6"),
- ListSupportedCharacterSets: aws.Bool(true),
- }
- result, err := svc.DescribeDBEngineVersions(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list DB instance settings
- //
- // This example lists settings for the specified DB instance.
- func ExampleRDS_DescribeDBInstances_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeDBInstancesInput{
- DBInstanceIdentifier: aws.String("mymysqlinstance"),
- }
- result, err := svc.DescribeDBInstances(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBInstanceNotFoundFault:
- fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list DB log file names
- //
- // This example lists matching log file names for the specified DB instance, file name
- // pattern, last write date in POSIX time with milleseconds, and minimum file size.
- func ExampleRDS_DescribeDBLogFiles_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeDBLogFilesInput{
- DBInstanceIdentifier: aws.String("mymysqlinstance"),
- FileLastWritten: aws.Int64(1470873600000),
- FileSize: aws.Int64(0),
- FilenameContains: aws.String("error"),
- }
- result, err := svc.DescribeDBLogFiles(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBInstanceNotFoundFault:
- fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list information about DB parameter groups
- //
- // This example lists information about the specified DB parameter group.
- func ExampleRDS_DescribeDBParameterGroups_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeDBParameterGroupsInput{
- DBParameterGroupName: aws.String("mymysqlparametergroup"),
- }
- result, err := svc.DescribeDBParameterGroups(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list information about DB parameters
- //
- // This example lists information for up to the first 20 system parameters for the specified
- // DB parameter group.
- func ExampleRDS_DescribeDBParameters_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeDBParametersInput{
- DBParameterGroupName: aws.String("mymysqlparametergroup"),
- MaxRecords: aws.Int64(20),
- Source: aws.String("system"),
- }
- result, err := svc.DescribeDBParameters(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list DB security group settings
- //
- // This example lists settings for the specified security group.
- func ExampleRDS_DescribeDBSecurityGroups_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeDBSecurityGroupsInput{
- DBSecurityGroupName: aws.String("mydbsecuritygroup"),
- }
- result, err := svc.DescribeDBSecurityGroups(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBSecurityGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list DB snapshot attributes
- //
- // This example lists attributes for the specified DB snapshot.
- func ExampleRDS_DescribeDBSnapshotAttributes_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeDBSnapshotAttributesInput{
- DBSnapshotIdentifier: aws.String("mydbsnapshot"),
- }
- result, err := svc.DescribeDBSnapshotAttributes(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list DB snapshot attributes
- //
- // This example lists all manually-created, shared snapshots for the specified DB instance.
- func ExampleRDS_DescribeDBSnapshots_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeDBSnapshotsInput{
- DBInstanceIdentifier: aws.String("mymysqlinstance"),
- IncludePublic: aws.Bool(false),
- IncludeShared: aws.Bool(true),
- SnapshotType: aws.String("manual"),
- }
- result, err := svc.DescribeDBSnapshots(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list information about DB subnet groups
- //
- // This example lists information about the specified DB subnet group.
- func ExampleRDS_DescribeDBSubnetGroups_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeDBSubnetGroupsInput{
- DBSubnetGroupName: aws.String("mydbsubnetgroup"),
- }
- result, err := svc.DescribeDBSubnetGroups(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBSubnetGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list default parameters for a DB cluster engine
- //
- // This example lists default parameters for the specified DB cluster engine.
- func ExampleRDS_DescribeEngineDefaultClusterParameters_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeEngineDefaultClusterParametersInput{
- DBParameterGroupFamily: aws.String("aurora5.6"),
- }
- result, err := svc.DescribeEngineDefaultClusterParameters(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list default parameters for a DB engine
- //
- // This example lists default parameters for the specified DB engine.
- func ExampleRDS_DescribeEngineDefaultParameters_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeEngineDefaultParametersInput{
- DBParameterGroupFamily: aws.String("mysql5.6"),
- }
- result, err := svc.DescribeEngineDefaultParameters(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list event categories.
- //
- // This example lists all DB instance event categories.
- func ExampleRDS_DescribeEventCategories_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeEventCategoriesInput{
- SourceType: aws.String("db-instance"),
- }
- result, err := svc.DescribeEventCategories(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list information about DB event notification subscriptions
- //
- // This example lists information for the specified DB event notification subscription.
- func ExampleRDS_DescribeEventSubscriptions_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeEventSubscriptionsInput{
- SubscriptionName: aws.String("mymysqleventsubscription"),
- }
- result, err := svc.DescribeEventSubscriptions(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeSubscriptionNotFoundFault:
- fmt.Println(rds.ErrCodeSubscriptionNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list information about events
- //
- // This example lists information for all backup-related events for the specified DB
- // instance for the past 7 days (7 days * 24 hours * 60 minutes = 10,080 minutes).
- func ExampleRDS_DescribeEvents_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeEventsInput{
- Duration: aws.Int64(10080),
- EventCategories: []*string{
- aws.String("backup"),
- },
- SourceIdentifier: aws.String("mymysqlinstance"),
- SourceType: aws.String("db-instance"),
- }
- result, err := svc.DescribeEvents(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list information about DB option group options
- //
- // This example lists information for all option group options for the specified DB
- // engine.
- func ExampleRDS_DescribeOptionGroupOptions_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeOptionGroupOptionsInput{
- EngineName: aws.String("mysql"),
- MajorEngineVersion: aws.String("5.6"),
- }
- result, err := svc.DescribeOptionGroupOptions(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list information about DB option groups
- //
- // This example lists information for all option groups for the specified DB engine.
- func ExampleRDS_DescribeOptionGroups_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeOptionGroupsInput{
- EngineName: aws.String("mysql"),
- MajorEngineVersion: aws.String("5.6"),
- }
- result, err := svc.DescribeOptionGroups(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeOptionGroupNotFoundFault:
- fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list information about orderable DB instance options
- //
- // This example lists information for all orderable DB instance options for the specified
- // DB engine, engine version, DB instance class, license model, and VPC settings.
- func ExampleRDS_DescribeOrderableDBInstanceOptions_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeOrderableDBInstanceOptionsInput{
- DBInstanceClass: aws.String("db.t2.micro"),
- Engine: aws.String("mysql"),
- EngineVersion: aws.String("5.6.27"),
- LicenseModel: aws.String("general-public-license"),
- Vpc: aws.Bool(true),
- }
- result, err := svc.DescribeOrderableDBInstanceOptions(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list information about pending maintenance actions
- //
- // This example lists information for all pending maintenance actions for the specified
- // DB instance.
- func ExampleRDS_DescribePendingMaintenanceActions_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribePendingMaintenanceActionsInput{
- ResourceIdentifier: aws.String("arn:aws:rds:us-east-1:992648334831:db:mymysqlinstance"),
- }
- result, err := svc.DescribePendingMaintenanceActions(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeResourceNotFoundFault:
- fmt.Println(rds.ErrCodeResourceNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list information about reserved DB instances
- //
- // This example lists information for all reserved DB instances for the specified DB
- // instance class, duration, product, offering type, and availability zone settings.
- func ExampleRDS_DescribeReservedDBInstances_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeReservedDBInstancesInput{
- DBInstanceClass: aws.String("db.t2.micro"),
- Duration: aws.String("1y"),
- MultiAZ: aws.Bool(false),
- OfferingType: aws.String("No Upfront"),
- ProductDescription: aws.String("mysql"),
- }
- result, err := svc.DescribeReservedDBInstances(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeReservedDBInstanceNotFoundFault:
- fmt.Println(rds.ErrCodeReservedDBInstanceNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list information about reserved DB instance offerings
- //
- // This example lists information for all reserved DB instance offerings for the specified
- // DB instance class, duration, product, offering type, and availability zone settings.
- func ExampleRDS_DescribeReservedDBInstancesOfferings_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeReservedDBInstancesOfferingsInput{
- DBInstanceClass: aws.String("db.t2.micro"),
- Duration: aws.String("1y"),
- MultiAZ: aws.Bool(false),
- OfferingType: aws.String("No Upfront"),
- ProductDescription: aws.String("mysql"),
- }
- result, err := svc.DescribeReservedDBInstancesOfferings(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeReservedDBInstancesOfferingNotFoundFault:
- fmt.Println(rds.ErrCodeReservedDBInstancesOfferingNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To describe source regions
- //
- // To list the AWS regions where a Read Replica can be created.
- func ExampleRDS_DescribeSourceRegions_shared00() {
- svc := rds.New(session.New())
- input := &rds.DescribeSourceRegionsInput{}
- result, err := svc.DescribeSourceRegions(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list information about DB log files
- //
- // This example lists information for the specified log file for the specified DB instance.
- func ExampleRDS_DownloadDBLogFilePortion_shared00() {
- svc := rds.New(session.New())
- input := &rds.DownloadDBLogFilePortionInput{
- DBInstanceIdentifier: aws.String("mymysqlinstance"),
- LogFileName: aws.String("mysqlUpgrade"),
- }
- result, err := svc.DownloadDBLogFilePortion(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBInstanceNotFoundFault:
- fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error())
- case rds.ErrCodeDBLogFileNotFoundFault:
- fmt.Println(rds.ErrCodeDBLogFileNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To perform a failover for a DB cluster
- //
- // This example performs a failover for the specified DB cluster to the specified DB
- // instance.
- func ExampleRDS_FailoverDBCluster_shared00() {
- svc := rds.New(session.New())
- input := &rds.FailoverDBClusterInput{
- DBClusterIdentifier: aws.String("myaurorainstance-cluster"),
- TargetDBInstanceIdentifier: aws.String("myaurorareplica"),
- }
- result, err := svc.FailoverDBCluster(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBClusterNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidDBClusterStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error())
- case rds.ErrCodeInvalidDBInstanceStateFault:
- fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list information about tags associated with a resource
- //
- // This example lists information about all tags associated with the specified DB option
- // group.
- func ExampleRDS_ListTagsForResource_shared00() {
- svc := rds.New(session.New())
- input := &rds.ListTagsForResourceInput{
- ResourceName: aws.String("arn:aws:rds:us-east-1:992648334831:og:mymysqloptiongroup"),
- }
- result, err := svc.ListTagsForResource(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBInstanceNotFoundFault:
- fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error())
- case rds.ErrCodeDBSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error())
- case rds.ErrCodeDBClusterNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To change DB cluster settings
- //
- // This example changes the specified settings for the specified DB cluster.
- func ExampleRDS_ModifyDBCluster_shared00() {
- svc := rds.New(session.New())
- input := &rds.ModifyDBClusterInput{
- ApplyImmediately: aws.Bool(true),
- DBClusterIdentifier: aws.String("mydbcluster"),
- MasterUserPassword: aws.String("mynewpassword"),
- NewDBClusterIdentifier: aws.String("mynewdbcluster"),
- PreferredBackupWindow: aws.String("04:00-04:30"),
- PreferredMaintenanceWindow: aws.String("Tue:05:00-Tue:05:30"),
- }
- result, err := svc.ModifyDBCluster(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBClusterNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidDBClusterStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error())
- case rds.ErrCodeStorageQuotaExceededFault:
- fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidVPCNetworkStateFault:
- fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error())
- case rds.ErrCodeInvalidDBSubnetGroupStateFault:
- fmt.Println(rds.ErrCodeInvalidDBSubnetGroupStateFault, aerr.Error())
- case rds.ErrCodeInvalidSubnet:
- fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error())
- case rds.ErrCodeDBClusterParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterParameterGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidDBSecurityGroupStateFault:
- fmt.Println(rds.ErrCodeInvalidDBSecurityGroupStateFault, aerr.Error())
- case rds.ErrCodeInvalidDBInstanceStateFault:
- fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error())
- case rds.ErrCodeDBClusterAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBClusterAlreadyExistsFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To change DB cluster parameter group settings
- //
- // This example immediately changes the specified setting for the specified DB cluster
- // parameter group.
- func ExampleRDS_ModifyDBClusterParameterGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.ModifyDBClusterParameterGroupInput{
- DBClusterParameterGroupName: aws.String("mydbclusterparametergroup"),
- Parameters: []*rds.Parameter{
- {
- ApplyMethod: aws.String("immediate"),
- ParameterName: aws.String("time_zone"),
- ParameterValue: aws.String("America/Phoenix"),
- },
- },
- }
- result, err := svc.ModifyDBClusterParameterGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidDBParameterGroupStateFault:
- fmt.Println(rds.ErrCodeInvalidDBParameterGroupStateFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To add or remove access to a manual DB cluster snapshot
- //
- // The following example gives two AWS accounts access to a manual DB cluster snapshot
- // and ensures that the DB cluster snapshot is private by removing the value "all".
- func ExampleRDS_ModifyDBClusterSnapshotAttribute_shared00() {
- svc := rds.New(session.New())
- input := &rds.ModifyDBClusterSnapshotAttributeInput{
- AttributeName: aws.String("restore"),
- DBClusterSnapshotIdentifier: aws.String("manual-cluster-snapshot1"),
- ValuesToAdd: []*string{
- aws.String("123451234512"),
- aws.String("123456789012"),
- },
- ValuesToRemove: []*string{
- aws.String("all"),
- },
- }
- result, err := svc.ModifyDBClusterSnapshotAttribute(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBClusterSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterSnapshotNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidDBClusterSnapshotStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterSnapshotStateFault, aerr.Error())
- case rds.ErrCodeSharedSnapshotQuotaExceededFault:
- fmt.Println(rds.ErrCodeSharedSnapshotQuotaExceededFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To change DB instance settings
- //
- // This example immediately changes the specified settings for the specified DB instance.
- func ExampleRDS_ModifyDBInstance_shared00() {
- svc := rds.New(session.New())
- input := &rds.ModifyDBInstanceInput{
- AllocatedStorage: aws.Int64(10),
- ApplyImmediately: aws.Bool(true),
- BackupRetentionPeriod: aws.Int64(1),
- DBInstanceClass: aws.String("db.t2.small"),
- DBInstanceIdentifier: aws.String("mymysqlinstance"),
- MasterUserPassword: aws.String("mynewpassword"),
- PreferredBackupWindow: aws.String("04:00-04:30"),
- PreferredMaintenanceWindow: aws.String("Tue:05:00-Tue:05:30"),
- }
- result, err := svc.ModifyDBInstance(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeInvalidDBInstanceStateFault:
- fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error())
- case rds.ErrCodeInvalidDBSecurityGroupStateFault:
- fmt.Println(rds.ErrCodeInvalidDBSecurityGroupStateFault, aerr.Error())
- case rds.ErrCodeDBInstanceAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBInstanceAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeDBInstanceNotFoundFault:
- fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error())
- case rds.ErrCodeDBSecurityGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeInsufficientDBInstanceCapacityFault:
- fmt.Println(rds.ErrCodeInsufficientDBInstanceCapacityFault, aerr.Error())
- case rds.ErrCodeStorageQuotaExceededFault:
- fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error())
- case rds.ErrCodeInvalidVPCNetworkStateFault:
- fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error())
- case rds.ErrCodeProvisionedIopsNotAvailableInAZFault:
- fmt.Println(rds.ErrCodeProvisionedIopsNotAvailableInAZFault, aerr.Error())
- case rds.ErrCodeOptionGroupNotFoundFault:
- fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDBUpgradeDependencyFailureFault:
- fmt.Println(rds.ErrCodeDBUpgradeDependencyFailureFault, aerr.Error())
- case rds.ErrCodeStorageTypeNotSupportedFault:
- fmt.Println(rds.ErrCodeStorageTypeNotSupportedFault, aerr.Error())
- case rds.ErrCodeAuthorizationNotFoundFault:
- fmt.Println(rds.ErrCodeAuthorizationNotFoundFault, aerr.Error())
- case rds.ErrCodeCertificateNotFoundFault:
- fmt.Println(rds.ErrCodeCertificateNotFoundFault, aerr.Error())
- case rds.ErrCodeDomainNotFoundFault:
- fmt.Println(rds.ErrCodeDomainNotFoundFault, aerr.Error())
- case rds.ErrCodeBackupPolicyNotFoundFault:
- fmt.Println(rds.ErrCodeBackupPolicyNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To change DB parameter group settings
- //
- // This example immediately changes the specified setting for the specified DB parameter
- // group.
- func ExampleRDS_ModifyDBParameterGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.ModifyDBParameterGroupInput{
- DBParameterGroupName: aws.String("mymysqlparametergroup"),
- Parameters: []*rds.Parameter{
- {
- ApplyMethod: aws.String("immediate"),
- ParameterName: aws.String("time_zone"),
- ParameterValue: aws.String("America/Phoenix"),
- },
- },
- }
- result, err := svc.ModifyDBParameterGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidDBParameterGroupStateFault:
- fmt.Println(rds.ErrCodeInvalidDBParameterGroupStateFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To change DB snapshot attributes
- //
- // This example adds the specified attribute for the specified DB snapshot.
- func ExampleRDS_ModifyDBSnapshotAttribute_shared00() {
- svc := rds.New(session.New())
- input := &rds.ModifyDBSnapshotAttributeInput{
- AttributeName: aws.String("restore"),
- DBSnapshotIdentifier: aws.String("mydbsnapshot"),
- ValuesToAdd: []*string{
- aws.String("all"),
- },
- }
- result, err := svc.ModifyDBSnapshotAttribute(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidDBSnapshotStateFault:
- fmt.Println(rds.ErrCodeInvalidDBSnapshotStateFault, aerr.Error())
- case rds.ErrCodeSharedSnapshotQuotaExceededFault:
- fmt.Println(rds.ErrCodeSharedSnapshotQuotaExceededFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To change DB subnet group settings
- //
- // This example changes the specified setting for the specified DB subnet group.
- func ExampleRDS_ModifyDBSubnetGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.ModifyDBSubnetGroupInput{
- DBSubnetGroupName: aws.String("mydbsubnetgroup"),
- SubnetIds: []*string{
- aws.String("subnet-70e1975a"),
- aws.String("subnet-747a5c49"),
- },
- }
- result, err := svc.ModifyDBSubnetGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBSubnetGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDBSubnetQuotaExceededFault:
- fmt.Println(rds.ErrCodeDBSubnetQuotaExceededFault, aerr.Error())
- case rds.ErrCodeSubnetAlreadyInUse:
- fmt.Println(rds.ErrCodeSubnetAlreadyInUse, aerr.Error())
- case rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs:
- fmt.Println(rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs, aerr.Error())
- case rds.ErrCodeInvalidSubnet:
- fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To change event notification subscription settings
- //
- // This example changes the specified setting for the specified event notification subscription.
- func ExampleRDS_ModifyEventSubscription_shared00() {
- svc := rds.New(session.New())
- input := &rds.ModifyEventSubscriptionInput{
- Enabled: aws.Bool(true),
- EventCategories: []*string{
- aws.String("deletion"),
- aws.String("low storage"),
- },
- SourceType: aws.String("db-instance"),
- SubscriptionName: aws.String("mymysqleventsubscription"),
- }
- result, err := svc.ModifyEventSubscription(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeEventSubscriptionQuotaExceededFault:
- fmt.Println(rds.ErrCodeEventSubscriptionQuotaExceededFault, aerr.Error())
- case rds.ErrCodeSubscriptionNotFoundFault:
- fmt.Println(rds.ErrCodeSubscriptionNotFoundFault, aerr.Error())
- case rds.ErrCodeSNSInvalidTopicFault:
- fmt.Println(rds.ErrCodeSNSInvalidTopicFault, aerr.Error())
- case rds.ErrCodeSNSNoAuthorizationFault:
- fmt.Println(rds.ErrCodeSNSNoAuthorizationFault, aerr.Error())
- case rds.ErrCodeSNSTopicArnNotFoundFault:
- fmt.Println(rds.ErrCodeSNSTopicArnNotFoundFault, aerr.Error())
- case rds.ErrCodeSubscriptionCategoryNotFoundFault:
- fmt.Println(rds.ErrCodeSubscriptionCategoryNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To modify an option group
- //
- // The following example adds an option to an option group.
- func ExampleRDS_ModifyOptionGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.ModifyOptionGroupInput{
- ApplyImmediately: aws.Bool(true),
- OptionGroupName: aws.String("myawsuser-og02"),
- OptionsToInclude: []*rds.OptionConfiguration{
- {
- DBSecurityGroupMemberships: []*string{
- aws.String("default"),
- },
- OptionName: aws.String("MEMCACHED"),
- },
- },
- }
- result, err := svc.ModifyOptionGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeInvalidOptionGroupStateFault:
- fmt.Println(rds.ErrCodeInvalidOptionGroupStateFault, aerr.Error())
- case rds.ErrCodeOptionGroupNotFoundFault:
- fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To promote a read replica
- //
- // This example promotes the specified read replica and sets its backup retention period
- // and preferred backup window.
- func ExampleRDS_PromoteReadReplica_shared00() {
- svc := rds.New(session.New())
- input := &rds.PromoteReadReplicaInput{
- BackupRetentionPeriod: aws.Int64(1),
- DBInstanceIdentifier: aws.String("mydbreadreplica"),
- PreferredBackupWindow: aws.String("03:30-04:00"),
- }
- result, err := svc.PromoteReadReplica(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeInvalidDBInstanceStateFault:
- fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error())
- case rds.ErrCodeDBInstanceNotFoundFault:
- fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To purchase a reserved DB instance offering
- //
- // This example purchases a reserved DB instance offering that matches the specified
- // settings.
- func ExampleRDS_PurchaseReservedDBInstancesOffering_shared00() {
- svc := rds.New(session.New())
- input := &rds.PurchaseReservedDBInstancesOfferingInput{
- ReservedDBInstanceId: aws.String("myreservationid"),
- ReservedDBInstancesOfferingId: aws.String("fb29428a-646d-4390-850e-5fe89926e727"),
- }
- result, err := svc.PurchaseReservedDBInstancesOffering(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeReservedDBInstancesOfferingNotFoundFault:
- fmt.Println(rds.ErrCodeReservedDBInstancesOfferingNotFoundFault, aerr.Error())
- case rds.ErrCodeReservedDBInstanceAlreadyExistsFault:
- fmt.Println(rds.ErrCodeReservedDBInstanceAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeReservedDBInstanceQuotaExceededFault:
- fmt.Println(rds.ErrCodeReservedDBInstanceQuotaExceededFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To reboot a DB instance
- //
- // This example reboots the specified DB instance without forcing a failover.
- func ExampleRDS_RebootDBInstance_shared00() {
- svc := rds.New(session.New())
- input := &rds.RebootDBInstanceInput{
- DBInstanceIdentifier: aws.String("mymysqlinstance"),
- ForceFailover: aws.Bool(false),
- }
- result, err := svc.RebootDBInstance(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeInvalidDBInstanceStateFault:
- fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error())
- case rds.ErrCodeDBInstanceNotFoundFault:
- fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To remove a source identifier from a DB event subscription
- //
- // This example removes the specified source identifier from the specified DB event
- // subscription.
- func ExampleRDS_RemoveSourceIdentifierFromSubscription_shared00() {
- svc := rds.New(session.New())
- input := &rds.RemoveSourceIdentifierFromSubscriptionInput{
- SourceIdentifier: aws.String("mymysqlinstance"),
- SubscriptionName: aws.String("myeventsubscription"),
- }
- result, err := svc.RemoveSourceIdentifierFromSubscription(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeSubscriptionNotFoundFault:
- fmt.Println(rds.ErrCodeSubscriptionNotFoundFault, aerr.Error())
- case rds.ErrCodeSourceNotFoundFault:
- fmt.Println(rds.ErrCodeSourceNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To remove tags from a resource
- //
- // This example removes the specified tag associated with the specified DB option group.
- func ExampleRDS_RemoveTagsFromResource_shared00() {
- svc := rds.New(session.New())
- input := &rds.RemoveTagsFromResourceInput{
- ResourceName: aws.String("arn:aws:rds:us-east-1:992648334831:og:mydboptiongroup"),
- TagKeys: []*string{
- aws.String("MyKey"),
- },
- }
- result, err := svc.RemoveTagsFromResource(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBInstanceNotFoundFault:
- fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error())
- case rds.ErrCodeDBSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error())
- case rds.ErrCodeDBClusterNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To reset the values of a DB cluster parameter group
- //
- // This example resets all parameters for the specified DB cluster parameter group to
- // their default values.
- func ExampleRDS_ResetDBClusterParameterGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.ResetDBClusterParameterGroupInput{
- DBClusterParameterGroupName: aws.String("mydbclusterparametergroup"),
- ResetAllParameters: aws.Bool(true),
- }
- result, err := svc.ResetDBClusterParameterGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeInvalidDBParameterGroupStateFault:
- fmt.Println(rds.ErrCodeInvalidDBParameterGroupStateFault, aerr.Error())
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To reset the values of a DB parameter group
- //
- // This example resets all parameters for the specified DB parameter group to their
- // default values.
- func ExampleRDS_ResetDBParameterGroup_shared00() {
- svc := rds.New(session.New())
- input := &rds.ResetDBParameterGroupInput{
- DBParameterGroupName: aws.String("mydbparametergroup"),
- ResetAllParameters: aws.Bool(true),
- }
- result, err := svc.ResetDBParameterGroup(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeInvalidDBParameterGroupStateFault:
- fmt.Println(rds.ErrCodeInvalidDBParameterGroupStateFault, aerr.Error())
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To restore an Amazon Aurora DB cluster from a DB cluster snapshot
- //
- // The following example restores an Amazon Aurora DB cluster from a DB cluster snapshot.
- func ExampleRDS_RestoreDBClusterFromSnapshot_shared00() {
- svc := rds.New(session.New())
- input := &rds.RestoreDBClusterFromSnapshotInput{
- DBClusterIdentifier: aws.String("restored-cluster1"),
- Engine: aws.String("aurora"),
- SnapshotIdentifier: aws.String("sample-cluster-snapshot1"),
- }
- result, err := svc.RestoreDBClusterFromSnapshot(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBClusterAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBClusterAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeDBClusterQuotaExceededFault:
- fmt.Println(rds.ErrCodeDBClusterQuotaExceededFault, aerr.Error())
- case rds.ErrCodeStorageQuotaExceededFault:
- fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDBSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error())
- case rds.ErrCodeDBClusterSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterSnapshotNotFoundFault, aerr.Error())
- case rds.ErrCodeInsufficientDBClusterCapacityFault:
- fmt.Println(rds.ErrCodeInsufficientDBClusterCapacityFault, aerr.Error())
- case rds.ErrCodeInsufficientStorageClusterCapacityFault:
- fmt.Println(rds.ErrCodeInsufficientStorageClusterCapacityFault, aerr.Error())
- case rds.ErrCodeInvalidDBSnapshotStateFault:
- fmt.Println(rds.ErrCodeInvalidDBSnapshotStateFault, aerr.Error())
- case rds.ErrCodeInvalidDBClusterSnapshotStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterSnapshotStateFault, aerr.Error())
- case rds.ErrCodeInvalidVPCNetworkStateFault:
- fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error())
- case rds.ErrCodeInvalidRestoreFault:
- fmt.Println(rds.ErrCodeInvalidRestoreFault, aerr.Error())
- case rds.ErrCodeInvalidSubnet:
- fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error())
- case rds.ErrCodeOptionGroupNotFoundFault:
- fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeKMSKeyNotAccessibleFault:
- fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, aerr.Error())
- case rds.ErrCodeDBClusterParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterParameterGroupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To restore a DB cluster to a point in time.
- //
- // The following example restores a DB cluster to a new DB cluster at a point in time
- // from the source DB cluster.
- func ExampleRDS_RestoreDBClusterToPointInTime_shared00() {
- svc := rds.New(session.New())
- input := &rds.RestoreDBClusterToPointInTimeInput{
- DBClusterIdentifier: aws.String("sample-restored-cluster1"),
- RestoreToTime: parseTime("2006-01-02T15:04:05Z", "2016-09-13T18:45:00Z"),
- SourceDBClusterIdentifier: aws.String("sample-cluster1"),
- }
- result, err := svc.RestoreDBClusterToPointInTime(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBClusterAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBClusterAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeDBClusterNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error())
- case rds.ErrCodeDBClusterQuotaExceededFault:
- fmt.Println(rds.ErrCodeDBClusterQuotaExceededFault, aerr.Error())
- case rds.ErrCodeDBClusterSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterSnapshotNotFoundFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeInsufficientDBClusterCapacityFault:
- fmt.Println(rds.ErrCodeInsufficientDBClusterCapacityFault, aerr.Error())
- case rds.ErrCodeInsufficientStorageClusterCapacityFault:
- fmt.Println(rds.ErrCodeInsufficientStorageClusterCapacityFault, aerr.Error())
- case rds.ErrCodeInvalidDBClusterSnapshotStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterSnapshotStateFault, aerr.Error())
- case rds.ErrCodeInvalidDBClusterStateFault:
- fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error())
- case rds.ErrCodeInvalidDBSnapshotStateFault:
- fmt.Println(rds.ErrCodeInvalidDBSnapshotStateFault, aerr.Error())
- case rds.ErrCodeInvalidRestoreFault:
- fmt.Println(rds.ErrCodeInvalidRestoreFault, aerr.Error())
- case rds.ErrCodeInvalidSubnet:
- fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error())
- case rds.ErrCodeInvalidVPCNetworkStateFault:
- fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error())
- case rds.ErrCodeKMSKeyNotAccessibleFault:
- fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, aerr.Error())
- case rds.ErrCodeOptionGroupNotFoundFault:
- fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeStorageQuotaExceededFault:
- fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error())
- case rds.ErrCodeDBClusterParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBClusterParameterGroupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To restore a DB instance from a DB snapshot.
- //
- // The following example restores a DB instance from a DB snapshot.
- func ExampleRDS_RestoreDBInstanceFromDBSnapshot_shared00() {
- svc := rds.New(session.New())
- input := &rds.RestoreDBInstanceFromDBSnapshotInput{
- DBInstanceIdentifier: aws.String("mysqldb-restored"),
- DBSnapshotIdentifier: aws.String("rds:mysqldb-2014-04-22-08-15"),
- }
- result, err := svc.RestoreDBInstanceFromDBSnapshot(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBInstanceAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBInstanceAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeDBSnapshotNotFoundFault:
- fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error())
- case rds.ErrCodeInstanceQuotaExceededFault:
- fmt.Println(rds.ErrCodeInstanceQuotaExceededFault, aerr.Error())
- case rds.ErrCodeInsufficientDBInstanceCapacityFault:
- fmt.Println(rds.ErrCodeInsufficientDBInstanceCapacityFault, aerr.Error())
- case rds.ErrCodeInvalidDBSnapshotStateFault:
- fmt.Println(rds.ErrCodeInvalidDBSnapshotStateFault, aerr.Error())
- case rds.ErrCodeStorageQuotaExceededFault:
- fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error())
- case rds.ErrCodeInvalidVPCNetworkStateFault:
- fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error())
- case rds.ErrCodeInvalidRestoreFault:
- fmt.Println(rds.ErrCodeInvalidRestoreFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs:
- fmt.Println(rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs, aerr.Error())
- case rds.ErrCodeInvalidSubnet:
- fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error())
- case rds.ErrCodeProvisionedIopsNotAvailableInAZFault:
- fmt.Println(rds.ErrCodeProvisionedIopsNotAvailableInAZFault, aerr.Error())
- case rds.ErrCodeOptionGroupNotFoundFault:
- fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeStorageTypeNotSupportedFault:
- fmt.Println(rds.ErrCodeStorageTypeNotSupportedFault, aerr.Error())
- case rds.ErrCodeAuthorizationNotFoundFault:
- fmt.Println(rds.ErrCodeAuthorizationNotFoundFault, aerr.Error())
- case rds.ErrCodeKMSKeyNotAccessibleFault:
- fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, aerr.Error())
- case rds.ErrCodeDBSecurityGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDomainNotFoundFault:
- fmt.Println(rds.ErrCodeDomainNotFoundFault, aerr.Error())
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeBackupPolicyNotFoundFault:
- fmt.Println(rds.ErrCodeBackupPolicyNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To restore a DB instance to a point in time.
- //
- // The following example restores a DB instance to a new DB instance at a point in time
- // from the source DB instance.
- func ExampleRDS_RestoreDBInstanceToPointInTime_shared00() {
- svc := rds.New(session.New())
- input := &rds.RestoreDBInstanceToPointInTimeInput{
- RestoreTime: parseTime("2006-01-02T15:04:05Z", "2016-09-13T18:45:00Z"),
- SourceDBInstanceIdentifier: aws.String("mysql-sample"),
- TargetDBInstanceIdentifier: aws.String("mysql-sample-restored"),
- }
- result, err := svc.RestoreDBInstanceToPointInTime(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBInstanceAlreadyExistsFault:
- fmt.Println(rds.ErrCodeDBInstanceAlreadyExistsFault, aerr.Error())
- case rds.ErrCodeDBInstanceNotFoundFault:
- fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error())
- case rds.ErrCodeInstanceQuotaExceededFault:
- fmt.Println(rds.ErrCodeInstanceQuotaExceededFault, aerr.Error())
- case rds.ErrCodeInsufficientDBInstanceCapacityFault:
- fmt.Println(rds.ErrCodeInsufficientDBInstanceCapacityFault, aerr.Error())
- case rds.ErrCodeInvalidDBInstanceStateFault:
- fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error())
- case rds.ErrCodePointInTimeRestoreNotEnabledFault:
- fmt.Println(rds.ErrCodePointInTimeRestoreNotEnabledFault, aerr.Error())
- case rds.ErrCodeStorageQuotaExceededFault:
- fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error())
- case rds.ErrCodeInvalidVPCNetworkStateFault:
- fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error())
- case rds.ErrCodeInvalidRestoreFault:
- fmt.Println(rds.ErrCodeInvalidRestoreFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs:
- fmt.Println(rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs, aerr.Error())
- case rds.ErrCodeInvalidSubnet:
- fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error())
- case rds.ErrCodeProvisionedIopsNotAvailableInAZFault:
- fmt.Println(rds.ErrCodeProvisionedIopsNotAvailableInAZFault, aerr.Error())
- case rds.ErrCodeOptionGroupNotFoundFault:
- fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeStorageTypeNotSupportedFault:
- fmt.Println(rds.ErrCodeStorageTypeNotSupportedFault, aerr.Error())
- case rds.ErrCodeAuthorizationNotFoundFault:
- fmt.Println(rds.ErrCodeAuthorizationNotFoundFault, aerr.Error())
- case rds.ErrCodeKMSKeyNotAccessibleFault:
- fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, aerr.Error())
- case rds.ErrCodeDBSecurityGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDomainNotFoundFault:
- fmt.Println(rds.ErrCodeDomainNotFoundFault, aerr.Error())
- case rds.ErrCodeBackupPolicyNotFoundFault:
- fmt.Println(rds.ErrCodeBackupPolicyNotFoundFault, aerr.Error())
- case rds.ErrCodeDBParameterGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeDBInstanceAutomatedBackupNotFoundFault:
- fmt.Println(rds.ErrCodeDBInstanceAutomatedBackupNotFoundFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To revoke ingress for a DB security group
- //
- // This example revokes ingress for the specified CIDR block associated with the specified
- // DB security group.
- func ExampleRDS_RevokeDBSecurityGroupIngress_shared00() {
- svc := rds.New(session.New())
- input := &rds.RevokeDBSecurityGroupIngressInput{
- CIDRIP: aws.String("203.0.113.5/32"),
- DBSecurityGroupName: aws.String("mydbsecuritygroup"),
- }
- result, err := svc.RevokeDBSecurityGroupIngress(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case rds.ErrCodeDBSecurityGroupNotFoundFault:
- fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, aerr.Error())
- case rds.ErrCodeAuthorizationNotFoundFault:
- fmt.Println(rds.ErrCodeAuthorizationNotFoundFault, aerr.Error())
- case rds.ErrCodeInvalidDBSecurityGroupStateFault:
- fmt.Println(rds.ErrCodeInvalidDBSecurityGroupStateFault, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
|