diff --git a/.doc_gen/metadata/bedrock-runtime_metadata.yaml b/.doc_gen/metadata/bedrock-runtime_metadata.yaml index b4fa169574d..06fe8ec61f0 100644 --- a/.doc_gen/metadata/bedrock-runtime_metadata.yaml +++ b/.doc_gen/metadata/bedrock-runtime_metadata.yaml @@ -555,6 +555,7 @@ bedrock-runtime_InvokeModel_Ai21LabsJurassic2: excerpts: - description: Use the Invoke Model API to send a text message. snippet_tags: + - gov2.bedrock-runtime.InvokeModelWrapper.struct - gov2.bedrock-runtime.InvokeJurassic2 JavaScript: versions: @@ -620,6 +621,7 @@ bedrock-runtime_InvokeModel_TitanText: excerpts: - description: Use the Invoke Model API to send a text message. snippet_tags: + - gov2.bedrock-runtime.InvokeModelWrapper.struct - gov2.bedrock-runtime.InvokeTitanText services: bedrock-runtime: {InvokeModel} @@ -669,6 +671,7 @@ bedrock-runtime_InvokeModel_AnthropicClaude: excerpts: - description: Invoke the Anthropic Claude 2 foundation model to generate text. snippet_tags: + - gov2.bedrock-runtime.InvokeModelWrapper.struct - gov2.bedrock-runtime.InvokeClaude PHP: versions: @@ -799,6 +802,7 @@ bedrock-runtime_InvokeModel_MetaLlama2: excerpts: - description: Use the Invoke Model API to send a text message. snippet_tags: + - gov2.bedrock-runtime.InvokeModelWrapper.struct - gov2.bedrock-runtime.InvokeLlama2 JavaScript: versions: @@ -972,6 +976,7 @@ bedrock-runtime_InvokeModelWithResponseStream_AnthropicClaude: excerpts: - description: Use the Invoke Model API to send a text message and process the response stream in real-time. snippet_tags: + - gov2.bedrock-runtime.InvokeModelWrapper.struct - gov2.bedrock-runtime.InvokeModelWithResponseStream JavaScript: versions: @@ -1195,6 +1200,7 @@ bedrock-runtime_InvokeModel_TitanImageGenerator: excerpts: - description: Create an image with the Amazon Titan Image Generator. snippet_tags: + - gov2.bedrock-runtime.InvokeModelWrapper.struct - gov2.bedrock-runtime.InvokeTitanImage PHP: versions: diff --git a/.doc_gen/metadata/dynamodb_metadata.yaml b/.doc_gen/metadata/dynamodb_metadata.yaml index b5a18e5ffac..071bf1c0a60 100644 --- a/.doc_gen/metadata/dynamodb_metadata.yaml +++ b/.doc_gen/metadata/dynamodb_metadata.yaml @@ -394,6 +394,8 @@ dynamodb_BatchWriteItem: snippet_tags: - gov2.dynamodb.TableBasics.struct - gov2.dynamodb.BatchWriteItem + - description: Define a Movie struct that is used in this example. + snippet_tags: - gov2.dynamodb.Movie.struct Java: versions: @@ -643,6 +645,8 @@ dynamodb_PutItem: snippet_tags: - gov2.dynamodb.TableBasics.struct - gov2.dynamodb.PutItem + - description: Define a Movie struct that is used in this example. + snippet_tags: - gov2.dynamodb.Movie.struct Kotlin: versions: @@ -780,6 +784,8 @@ dynamodb_GetItem: snippet_tags: - gov2.dynamodb.TableBasics.struct - gov2.dynamodb.GetItem + - description: Define a Movie struct that is used in this example. + snippet_tags: - gov2.dynamodb.Movie.struct Kotlin: versions: @@ -908,6 +914,8 @@ dynamodb_UpdateItem: snippet_tags: - gov2.dynamodb.TableBasics.struct - gov2.dynamodb.UpdateItem + - description: Define a Movie struct that is used in this example. + snippet_tags: - gov2.dynamodb.Movie.struct Kotlin: versions: @@ -1024,6 +1032,8 @@ dynamodb_DeleteItem: snippet_tags: - gov2.dynamodb.TableBasics.struct - gov2.dynamodb.DeleteItem + - description: Define a Movie struct that is used in this example. + snippet_tags: - gov2.dynamodb.Movie.struct Kotlin: versions: @@ -1309,6 +1319,8 @@ dynamodb_Query: snippet_tags: - gov2.dynamodb.TableBasics.struct - gov2.dynamodb.Query + - description: Define a Movie struct that is used in this example. + snippet_tags: - gov2.dynamodb.Movie.struct Kotlin: versions: @@ -1448,6 +1460,8 @@ dynamodb_Scan: snippet_tags: - gov2.dynamodb.TableBasics.struct - gov2.dynamodb.Scan + - description: Define a Movie struct that is used in this example. + snippet_tags: - gov2.dynamodb.Movie.struct Kotlin: versions: @@ -1578,6 +1592,9 @@ dynamodb_ExecuteStatement: - sdk_version: 2 github: gov2/dynamodb excerpts: + - description: Define a function receiver struct for the example. + snippet_tags: + - gov2.dynamodb.PartiQLRunner.struct - description: Use an INSERT statement to add an item. snippet_tags: - gov2.dynamodb.ExecuteStatement.Insert @@ -1699,6 +1716,9 @@ dynamodb_BatchExecuteStatement: - sdk_version: 2 github: gov2/dynamodb excerpts: + - description: Define a function receiver struct for the example. + snippet_tags: + - gov2.dynamodb.PartiQLRunner.struct - description: Use batches of INSERT statements to add items. snippet_tags: - gov2.dynamodb.BatchExecuteStatement.Insert diff --git a/.doc_gen/metadata/lambda_metadata.yaml b/.doc_gen/metadata/lambda_metadata.yaml index b65eca62c4a..83e34ec59a3 100644 --- a/.doc_gen/metadata/lambda_metadata.yaml +++ b/.doc_gen/metadata/lambda_metadata.yaml @@ -794,9 +794,6 @@ lambda_Scenario_GettingStartedFunctions: - description: Create a struct that wraps individual &LAM; actions. snippet_tags: - gov2.lambda.FunctionWrapper.complete - - description: Create a struct that implements functions to help run the scenario. - snippet_tags: - - gov2.lambda.GetStartedFunctions_Helper - description: Define a &LAM; handler that increments a number. snippet_tags: - gov2.lambda.handlers.increment diff --git a/.doc_gen/metadata/s3_metadata.yaml b/.doc_gen/metadata/s3_metadata.yaml index 35a205cc9f3..3a298d854f1 100644 --- a/.doc_gen/metadata/s3_metadata.yaml +++ b/.doc_gen/metadata/s3_metadata.yaml @@ -2742,6 +2742,7 @@ s3_Scenario_PresignedUrl: - description: Run an interactive example that generates and uses presigned URLs to upload, download, and delete an S3 object. snippet_tags: + - gov2.s3.Scenario_Presigning.imports - gov2.s3.Scenario_Presigning - description: Define an HTTP request wrapper used by the example to make HTTP requests. snippet_tags: diff --git a/.doc_gen/metadata/sqs_metadata.yaml b/.doc_gen/metadata/sqs_metadata.yaml index 8cfa6faa714..0d6d3ddfb9a 100644 --- a/.doc_gen/metadata/sqs_metadata.yaml +++ b/.doc_gen/metadata/sqs_metadata.yaml @@ -980,6 +980,9 @@ sqs_Scenario_TopicsAndQueues: - description: Define a struct that wraps &SQS; actions used in this example. snippet_tags: - gov2.sqs.SqsActions.complete + - description: Clean up resources. + snippet_tags: + - gov2.workflows.TopicsAndQueues.Resources.complete JavaScript: versions: - sdk_version: 3 diff --git a/gov2/aurora/actions/clusters.go b/gov2/aurora/actions/clusters.go index e515a32db87..0aa8e76fc32 100644 --- a/gov2/aurora/actions/clusters.go +++ b/gov2/aurora/actions/clusters.go @@ -2,6 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 package actions +// snippet-start:[gov2.aurora.DbClusters.complete] +// snippet-start:[gov2.aurora.DbClusters.struct] + import ( "context" "errors" @@ -12,9 +15,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/rds/types" ) -// snippet-start:[gov2.aurora.DbClusters.complete] -// snippet-start:[gov2.aurora.DbClusters.struct] - type DbClusters struct { AuroraClient *rds.Client } diff --git a/gov2/aurora/scenarios/get_started_clusters.go b/gov2/aurora/scenarios/get_started_clusters.go index a5f0d7c55f8..d8233bfda0f 100644 --- a/gov2/aurora/scenarios/get_started_clusters.go +++ b/gov2/aurora/scenarios/get_started_clusters.go @@ -3,6 +3,8 @@ package scenarios +// snippet-start:[gov2.aurora.Scenario_GetStartedClusters] + import ( "aurora/actions" "context" @@ -21,26 +23,6 @@ import ( "github.com/google/uuid" ) -// IScenarioHelper abstracts the function from a scenario so that it -// can be mocked for unit testing. -type IScenarioHelper interface { - Pause(secs int) - UniqueId() string -} -type ScenarioHelper struct{} - -// Pause waits for the specified number of seconds. -func (helper ScenarioHelper) Pause(secs int) { - time.Sleep(time.Duration(secs) * time.Second) -} - -// UniqueId returns a new UUID. -func (helper ScenarioHelper) UniqueId() string { - return uuid.New().String() -} - -// snippet-start:[gov2.aurora.Scenario_GetStartedClusters] - // GetStartedClusters is an interactive example that shows you how to use the AWS SDK for Go // with Amazon Aurora to do the following: // @@ -384,4 +366,22 @@ func (scenario GetStartedClusters) Cleanup(ctx context.Context, dbInstance *type } } +// IScenarioHelper abstracts the function from a scenario so that it +// can be mocked for unit testing. +type IScenarioHelper interface { + Pause(secs int) + UniqueId() string +} +type ScenarioHelper struct{} + +// Pause waits for the specified number of seconds. +func (helper ScenarioHelper) Pause(secs int) { + time.Sleep(time.Duration(secs) * time.Second) +} + +// UniqueId returns a new UUID. +func (helper ScenarioHelper) UniqueId() string { + return uuid.New().String() +} + // snippet-end:[gov2.aurora.Scenario_GetStartedClusters] diff --git a/gov2/bedrock-runtime/README.md b/gov2/bedrock-runtime/README.md index b111ed8e75f..6b8f6d67156 100644 --- a/gov2/bedrock-runtime/README.md +++ b/gov2/bedrock-runtime/README.md @@ -42,24 +42,24 @@ functions within the same service. ### AI21 Labs Jurassic-2 -- [InvokeModel](actions/invoke_model.go#L83) +- [InvokeModel](actions/invoke_model.go#L7) ### Amazon Titan Image Generator -- [InvokeModel](actions/invoke_model.go#L191) +- [InvokeModel](actions/invoke_model.go#L7) ### Amazon Titan Text -- [InvokeModel](actions/invoke_model.go#L261) +- [InvokeModel](actions/invoke_model.go#L7) ### Anthropic Claude -- [InvokeModel](actions/invoke_model.go#L27) +- [InvokeModel](actions/invoke_model.go#L7) - [InvokeModelWithResponseStream](actions/invoke_model_with_response_stream.go#L30) ### Meta Llama -- [InvokeModel: Llama 2](actions/invoke_model.go#L140) +- [InvokeModel: Llama 2](actions/invoke_model.go#L7) diff --git a/gov2/bedrock-runtime/actions/invoke_model.go b/gov2/bedrock-runtime/actions/invoke_model.go index bf44ebb8a06..9863ffd5c79 100644 --- a/gov2/bedrock-runtime/actions/invoke_model.go +++ b/gov2/bedrock-runtime/actions/invoke_model.go @@ -3,6 +3,9 @@ package actions +// snippet-start:[gov2.bedrock-runtime.InvokeModelWrapper.complete] +// snippet-start:[gov2.bedrock-runtime.InvokeModelWrapper.struct] + import ( "context" "encoding/json" @@ -13,9 +16,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/bedrockruntime" ) -// snippet-start:[gov2.bedrock-runtime.InvokeModelWrapper.complete] -// snippet-start:[gov2.bedrock-runtime.InvokeModelWrapper.struct] - // InvokeModelWrapper encapsulates Amazon Bedrock actions used in the examples. // It contains a Bedrock Runtime client that is used to invoke foundation models. type InvokeModelWrapper struct { diff --git a/gov2/bedrock-runtime/actions/invoke_model_with_response_stream.go b/gov2/bedrock-runtime/actions/invoke_model_with_response_stream.go index b608dc077a4..17cd6cf82da 100644 --- a/gov2/bedrock-runtime/actions/invoke_model_with_response_stream.go +++ b/gov2/bedrock-runtime/actions/invoke_model_with_response_stream.go @@ -3,6 +3,9 @@ package actions +// snippet-start:[gov2.bedrock-runtime.InvokeModelWithResponseStreamWrapper.complete] +// snippet-start:[gov2.bedrock-runtime.InvokeModelWithResponseStreamWrapper.struct] + import ( "bytes" "context" @@ -16,9 +19,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/bedrockruntime/types" ) -// snippet-start:[gov2.bedrock-runtime.InvokeModelWithResponseStreamWrapper.complete] -// snippet-start:[gov2.bedrock-runtime.InvokeModelWithResponseStreamWrapper.struct] - // InvokeModelWithResponseStreamWrapper encapsulates Amazon Bedrock actions used in the examples. // It contains a Bedrock Runtime client that is used to invoke foundation models. type InvokeModelWithResponseStreamWrapper struct { diff --git a/gov2/bedrock-runtime/scenarios/scenario_invoke_models.go b/gov2/bedrock-runtime/scenarios/scenario_invoke_models.go index 74824fb50ff..2a297333728 100644 --- a/gov2/bedrock-runtime/scenarios/scenario_invoke_models.go +++ b/gov2/bedrock-runtime/scenarios/scenario_invoke_models.go @@ -3,6 +3,8 @@ package scenarios +// snippet-start:[gov2.bedrock-runtime.Scenario_InvokeModels] + import ( "context" "encoding/base64" @@ -19,8 +21,6 @@ import ( "github.com/awsdocs/aws-doc-sdk-examples/gov2/demotools" ) -// snippet-start:[gov2.bedrock-runtime.Scenario_InvokeModels] - // InvokeModelsScenario demonstrates how to use the Amazon Bedrock Runtime client // to invoke various foundation models for text and image generation // @@ -28,7 +28,7 @@ import ( // 2. Generate text with AI21 Labs Jurassic-2 // 3. Generate text with Meta Llama 2 Chat // 4. Generate text and asynchronously process the response stream with Anthropic Claude 2 -// 5. Generate and image with the Amazon Titan image generation model +// 5. Generate an image with the Amazon Titan image generation model // 6. Generate text with Amazon Titan Text G1 Express model type InvokeModelsScenario struct { sdkConfig aws.Config diff --git a/gov2/bedrock/actions/foundation_model.go b/gov2/bedrock/actions/foundation_model.go index b570c06b70d..935ef33b483 100644 --- a/gov2/bedrock/actions/foundation_model.go +++ b/gov2/bedrock/actions/foundation_model.go @@ -3,6 +3,9 @@ package actions +// snippet-start:[gov2.bedrock.FoundationModelWrapper.complete] +// snippet-start:[gov2.bedrock.FoundationModelWrapper.struct] + import ( "context" "log" @@ -11,9 +14,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/bedrock/types" ) -// snippet-start:[gov2.bedrock.FoundationModelWrapper.complete] -// snippet-start:[gov2.bedrock.FoundationModelWrapper.struct] - // FoundationModelWrapper encapsulates Amazon Bedrock actions used in the examples. // It contains a Bedrock service client that is used to perform foundation model actions. type FoundationModelWrapper struct { diff --git a/gov2/cognito/README.md b/gov2/cognito/README.md index cabd23a9610..b49a96ff934 100644 --- a/gov2/cognito/README.md +++ b/gov2/cognito/README.md @@ -38,15 +38,15 @@ For prerequisites, see the [README](../README.md#Prerequisites) in the `gov2` fo Code excerpts that show you how to call individual service functions. -- [AdminCreateUser](../workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go#L183) -- [AdminSetUserPassword](../workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go#L208) -- [ConfirmForgotPassword](../workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go#L145) -- [DeleteUser](../workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go#L168) -- [ForgotPassword](../workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go#L128) -- [InitiateAuth](../workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go#L103) +- [AdminCreateUser](../workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go#L182) +- [AdminSetUserPassword](../workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go#L207) +- [ConfirmForgotPassword](../workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go#L144) +- [DeleteUser](../workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go#L167) +- [ForgotPassword](../workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go#L127) +- [InitiateAuth](../workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go#L102) - [ListUserPools](hello/hello.go#L4) -- [SignUp](../workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go#L75) -- [UpdateUserPool](../workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go#L26) +- [SignUp](../workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go#L74) +- [UpdateUserPool](../workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go#L25) ### Scenarios diff --git a/gov2/dynamodb/README.md b/gov2/dynamodb/README.md index 31717fdcbea..5077150b9a8 100644 --- a/gov2/dynamodb/README.md +++ b/gov2/dynamodb/README.md @@ -40,13 +40,13 @@ Code examples that show you how to perform the essential operations within a ser Code excerpts that show you how to call individual service functions. -- [BatchExecuteStatement](actions/partiql.go#L164) +- [BatchExecuteStatement](actions/partiql.go#L7) - [BatchWriteItem](actions/table_basics.go#L177) - [CreateTable](actions/table_basics.go#L54) - [DeleteItem](actions/table_basics.go#L332) - [DeleteTable](actions/table_basics.go#L347) - [DescribeTable](actions/table_basics.go#L31) -- [ExecuteStatement](actions/partiql.go#L30) +- [ExecuteStatement](actions/partiql.go#L7) - [GetItem](actions/table_basics.go#L221) - [ListTables](actions/table_basics.go#L99) - [PutItem](actions/table_basics.go#L121) diff --git a/gov2/dynamodb/actions/movie.go b/gov2/dynamodb/actions/movie.go index 9d915a99187..e1e92f3d428 100644 --- a/gov2/dynamodb/actions/movie.go +++ b/gov2/dynamodb/actions/movie.go @@ -3,6 +3,8 @@ package actions +// snippet-start:[gov2.dynamodb.Movie.struct] + import ( "archive/zip" "bytes" @@ -16,8 +18,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) -// snippet-start:[gov2.dynamodb.Movie.struct] - // Movie encapsulates data about a movie. Title and Year are the composite primary key // of the movie in Amazon DynamoDB. Title is the sort key, Year is the partition key, // and Info is additional data. diff --git a/gov2/dynamodb/actions/partiql.go b/gov2/dynamodb/actions/partiql.go index 399350608d4..7da8706a750 100644 --- a/gov2/dynamodb/actions/partiql.go +++ b/gov2/dynamodb/actions/partiql.go @@ -3,6 +3,9 @@ package actions +// snippet-start:[gov2.dynamodb.PartiQLRunner.complete] +// snippet-start:[gov2.dynamodb.PartiQLRunner.struct] + import ( "context" "fmt" @@ -14,9 +17,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) -// snippet-start:[gov2.dynamodb.PartiQLRunner.complete] -// snippet-start:[gov2.dynamodb.PartiQLRunner.struct] - // PartiQLRunner encapsulates the Amazon DynamoDB service actions used in the // PartiQL examples. It contains a DynamoDB service client that is used to act on the // specified table. diff --git a/gov2/dynamodb/actions/table_basics.go b/gov2/dynamodb/actions/table_basics.go index b7f07d38a2f..57c2241047c 100644 --- a/gov2/dynamodb/actions/table_basics.go +++ b/gov2/dynamodb/actions/table_basics.go @@ -3,6 +3,9 @@ package actions +// snippet-start:[gov2.dynamodb.TableBasics.complete] +// snippet-start:[gov2.dynamodb.TableBasics.struct] + import ( "context" "errors" @@ -16,9 +19,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) -// snippet-start:[gov2.dynamodb.TableBasics.complete] -// snippet-start:[gov2.dynamodb.TableBasics.struct] - // TableBasics encapsulates the Amazon DynamoDB service actions used in the examples. // It contains a DynamoDB service client that is used to act on the specified table. type TableBasics struct { diff --git a/gov2/dynamodb/scenarios/scenario_movie_table.go b/gov2/dynamodb/scenarios/scenario_movie_table.go index 7a96ad2f052..90bb29dd9cc 100644 --- a/gov2/dynamodb/scenarios/scenario_movie_table.go +++ b/gov2/dynamodb/scenarios/scenario_movie_table.go @@ -3,6 +3,8 @@ package scenarios +// snippet-start:[gov2.dynamodb.Scenario_GettingStartedMovies] + import ( "context" "fmt" @@ -15,8 +17,6 @@ import ( "github.com/awsdocs/aws-doc-sdk-examples/gov2/dynamodb/actions" ) -// snippet-start:[gov2.dynamodb.Scenario_GettingStartedMovies] - // RunMovieScenario is an interactive example that shows you how to use the AWS SDK for Go // to create and use an Amazon DynamoDB table that stores data about movies. // diff --git a/gov2/dynamodb/scenarios/scenario_partiql_batch.go b/gov2/dynamodb/scenarios/scenario_partiql_batch.go index ea564aac384..c6c2fff5cb2 100644 --- a/gov2/dynamodb/scenarios/scenario_partiql_batch.go +++ b/gov2/dynamodb/scenarios/scenario_partiql_batch.go @@ -3,6 +3,8 @@ package scenarios +// snippet-start:[gov2.dynamodb.Scenario_PartiQLBatch] + import ( "context" "fmt" @@ -15,8 +17,6 @@ import ( "github.com/awsdocs/aws-doc-sdk-examples/gov2/dynamodb/actions" ) -// snippet-start:[gov2.dynamodb.Scenario_PartiQLBatch] - // RunPartiQLBatchScenario shows you how to use the AWS SDK for Go // to run batches of PartiQL statements to query a table that stores data about movies. // diff --git a/gov2/dynamodb/scenarios/scenario_partiql_single.go b/gov2/dynamodb/scenarios/scenario_partiql_single.go index f180be84587..81661e25e9f 100644 --- a/gov2/dynamodb/scenarios/scenario_partiql_single.go +++ b/gov2/dynamodb/scenarios/scenario_partiql_single.go @@ -3,6 +3,8 @@ package scenarios +// snippet-start:[gov2.dynamodb.Scenario_PartiQLSingle] + import ( "context" "fmt" @@ -15,8 +17,6 @@ import ( "github.com/awsdocs/aws-doc-sdk-examples/gov2/dynamodb/actions" ) -// snippet-start:[gov2.dynamodb.Scenario_PartiQLSingle] - // RunPartiQLSingleScenario shows you how to use the AWS SDK for Go // to use PartiQL to query a table that stores data about movies. // diff --git a/gov2/iam/README.md b/gov2/iam/README.md index 7b2fb7ec6bf..05c8f759c4d 100644 --- a/gov2/iam/README.md +++ b/gov2/iam/README.md @@ -47,25 +47,25 @@ Code excerpts that show you how to call individual service functions. - [AttachRolePolicy](actions/roles.go#L133) - [CreateAccessKey](actions/users.go#L175) -- [CreatePolicy](actions/policies.go#L65) +- [CreatePolicy](actions/policies.go#L46) - [CreateRole](actions/roles.go#L46) - [CreateServiceLinkedRole](actions/roles.go#L98) - [CreateUser](actions/users.go#L74) - [DeleteAccessKey](actions/users.go#L193) -- [DeletePolicy](actions/policies.go#L118) +- [DeletePolicy](actions/policies.go#L114) - [DeleteRole](actions/roles.go#L201) - [DeleteServiceLinkedRole](actions/roles.go#L118) - [DeleteUser](actions/users.go#L160) - [DeleteUserPolicy](actions/users.go#L144) - [DetachRolePolicy](actions/roles.go#L167) - [GetAccountPasswordPolicy](actions/account.go#L26) -- [GetPolicy](actions/policies.go#L100) +- [GetPolicy](actions/policies.go#L96) - [GetRole](actions/roles.go#L81) - [GetUser](actions/users.go#L47) - [ListAccessKeys](actions/users.go#L209) - [ListAttachedRolePolicies](actions/roles.go#L149) - [ListGroups](actions/groups.go#L27) -- [ListPolicies](actions/policies.go#L47) +- [ListPolicies](actions/policies.go#L28) - [ListRolePolicies](actions/roles.go#L183) - [ListRoles](actions/roles.go#L28) - [ListSAMLProviders](actions/account.go#L44) diff --git a/gov2/iam/actions/account.go b/gov2/iam/actions/account.go index c5c2047b891..0b67cbc90b4 100644 --- a/gov2/iam/actions/account.go +++ b/gov2/iam/actions/account.go @@ -3,6 +3,9 @@ package actions +// snippet-start:[gov2.iam.AccountWrapper.complete] +// snippet-start:[gov2.iam.AccountWrapper.struct] + import ( "context" "log" @@ -11,9 +14,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/iam/types" ) -// snippet-start:[gov2.iam.AccountWrapper.complete] -// snippet-start:[gov2.iam.AccountWrapper.struct] - // AccountWrapper encapsulates AWS Identity and Access Management (IAM) account actions // used in the examples. // It contains an IAM service client that is used to perform account actions. diff --git a/gov2/iam/actions/groups.go b/gov2/iam/actions/groups.go index aee6780e3d9..0da19684108 100644 --- a/gov2/iam/actions/groups.go +++ b/gov2/iam/actions/groups.go @@ -3,6 +3,9 @@ package actions +// snippet-start:[gov2.iam.GroupWrapper.complete] +// snippet-start:[gov2.iam.GroupWrapper.struct] + import ( "context" "log" @@ -12,9 +15,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/iam/types" ) -// snippet-start:[gov2.iam.GroupWrapper.complete] -// snippet-start:[gov2.iam.GroupWrapper.struct] - // GroupWrapper encapsulates AWS Identity and Access Management (IAM) group actions // used in the examples. // It contains an IAM service client that is used to perform group actions. diff --git a/gov2/iam/actions/policies.go b/gov2/iam/actions/policies.go index 0c945973b4a..62308776d4f 100644 --- a/gov2/iam/actions/policies.go +++ b/gov2/iam/actions/policies.go @@ -3,6 +3,9 @@ package actions +// snippet-start:[gov2.iam.PolicyWrapper.complete] +// snippet-start:[gov2.iam.PolicyWrapper.struct] + import ( "context" "encoding/json" @@ -13,28 +16,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/iam/types" ) -// snippet-start:[gov2.iam.PolicyWrapper.complete] -// snippet-start:[gov2.iam.PolicyDocument.struct] - -// PolicyDocument defines a policy document as a Go struct that can be serialized -// to JSON. -type PolicyDocument struct { - Version string - Statement []PolicyStatement -} - -// PolicyStatement defines a statement in a policy document. -type PolicyStatement struct { - Effect string - Action []string - Principal map[string]string `json:",omitempty"` - Resource *string `json:",omitempty"` -} - -// snippet-end:[gov2.iam.PolicyDocument.struct] - -// snippet-start:[gov2.iam.PolicyWrapper.struct] - // PolicyWrapper encapsulates AWS Identity and Access Management (IAM) policy actions // used in the examples. // It contains an IAM service client that is used to perform policy actions. @@ -64,6 +45,21 @@ func (wrapper PolicyWrapper) ListPolicies(ctx context.Context, maxPolicies int32 // snippet-start:[gov2.iam.CreatePolicy] +// PolicyDocument defines a policy document as a Go struct that can be serialized +// to JSON. +type PolicyDocument struct { + Version string + Statement []PolicyStatement +} + +// PolicyStatement defines a statement in a policy document. +type PolicyStatement struct { + Effect string + Action []string + Principal map[string]string `json:",omitempty"` + Resource *string `json:",omitempty"` +} + // CreatePolicy creates a policy that grants a list of actions to the specified resource. // PolicyDocument shows how to work with a policy document as a data structure and // serialize it to JSON by using Go's JSON marshaler. diff --git a/gov2/iam/actions/roles.go b/gov2/iam/actions/roles.go index 596d916a4f7..f9bdf31205e 100644 --- a/gov2/iam/actions/roles.go +++ b/gov2/iam/actions/roles.go @@ -3,6 +3,9 @@ package actions +// snippet-start:[gov2.iam.RoleWrapper.complete] +// snippet-start:[gov2.iam.RoleWrapper.struct] + import ( "context" "encoding/json" @@ -13,9 +16,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/iam/types" ) -// snippet-start:[gov2.iam.RoleWrapper.complete] -// snippet-start:[gov2.iam.RoleWrapper.struct] - // RoleWrapper encapsulates AWS Identity and Access Management (IAM) role actions // used in the examples. // It contains an IAM service client that is used to perform role actions. diff --git a/gov2/iam/actions/users.go b/gov2/iam/actions/users.go index ff7477a97d1..c5d98d1aeb5 100644 --- a/gov2/iam/actions/users.go +++ b/gov2/iam/actions/users.go @@ -3,6 +3,9 @@ package actions +// snippet-start:[gov2.iam.UserWrapper.complete] +// snippet-start:[gov2.iam.UserWrapper.struct] + import ( "context" "encoding/json" @@ -15,9 +18,6 @@ import ( "github.com/aws/smithy-go" ) -// snippet-start:[gov2.iam.UserWrapper.complete] -// snippet-start:[gov2.iam.UserWrapper.struct] - // UserWrapper encapsulates user actions used in the examples. // It contains an IAM service client that is used to perform user actions. type UserWrapper struct { diff --git a/gov2/iam/scenarios/scenario_assume_role.go b/gov2/iam/scenarios/scenario_assume_role.go index 703bbe8e31e..b9d479c8051 100644 --- a/gov2/iam/scenarios/scenario_assume_role.go +++ b/gov2/iam/scenarios/scenario_assume_role.go @@ -3,6 +3,8 @@ package scenarios +// snippet-start:[gov2.iam.Scenario_AssumeRole] + import ( "context" "errors" @@ -24,32 +26,6 @@ import ( "github.com/awsdocs/aws-doc-sdk-examples/gov2/iam/actions" ) -// IScenarioHelper abstracts input and wait functions from a scenario so that they -// can be mocked for unit testing. -type IScenarioHelper interface { - GetName() string - Pause(secs int) -} - -const rMax = 100000 - -type ScenarioHelper struct { - Prefix string - Random *rand.Rand -} - -// GetName returns a unique name formed of a prefix and a random number. -func (helper *ScenarioHelper) GetName() string { - return fmt.Sprintf("%v%v", helper.Prefix, helper.Random.Intn(rMax)) -} - -// Pause waits for the specified number of seconds. -func (helper ScenarioHelper) Pause(secs int) { - time.Sleep(time.Duration(secs) * time.Second) -} - -// snippet-start:[gov2.iam.Scenario_AssumeRole] - // AssumeRoleScenario shows you how to use the AWS Identity and Access Management (IAM) // service to perform the following actions: // @@ -342,4 +318,28 @@ func (scenario AssumeRoleScenario) Cleanup(ctx context.Context, user *types.User } +// IScenarioHelper abstracts input and wait functions from a scenario so that they +// can be mocked for unit testing. +type IScenarioHelper interface { + GetName() string + Pause(secs int) +} + +const rMax = 100000 + +type ScenarioHelper struct { + Prefix string + Random *rand.Rand +} + +// GetName returns a unique name formed of a prefix and a random number. +func (helper *ScenarioHelper) GetName() string { + return fmt.Sprintf("%v%v", helper.Prefix, helper.Random.Intn(rMax)) +} + +// Pause waits for the specified number of seconds. +func (helper ScenarioHelper) Pause(secs int) { + time.Sleep(time.Duration(secs) * time.Second) +} + // snippet-end:[gov2.iam.Scenario_AssumeRole] diff --git a/gov2/lambda/actions/functions.go b/gov2/lambda/actions/functions.go index 332c261d2c5..07879ebc07a 100644 --- a/gov2/lambda/actions/functions.go +++ b/gov2/lambda/actions/functions.go @@ -3,6 +3,9 @@ package actions +// snippet-start:[gov2.lambda.FunctionWrapper.complete] +// snippet-start:[gov2.lambda.FunctionWrapper.struct] + import ( "bytes" "context" @@ -16,9 +19,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/lambda/types" ) -// snippet-start:[gov2.lambda.FunctionWrapper.complete] -// snippet-start:[gov2.lambda.FunctionWrapper.struct] - // FunctionWrapper encapsulates function actions used in the examples. // It contains an AWS Lambda service client that is used to perform user actions. type FunctionWrapper struct { diff --git a/gov2/lambda/scenarios/scenario_get_started_functions.go b/gov2/lambda/scenarios/scenario_get_started_functions.go index 3193e145306..e7deacda0fb 100644 --- a/gov2/lambda/scenarios/scenario_get_started_functions.go +++ b/gov2/lambda/scenarios/scenario_get_started_functions.go @@ -3,6 +3,8 @@ package scenarios +// snippet-start:[gov2.lambda.Scenario_GetStartedFunctions] + import ( "archive/zip" "bytes" @@ -24,59 +26,6 @@ import ( "github.com/awsdocs/aws-doc-sdk-examples/gov2/lambda/actions" ) -// snippet-start:[gov2.lambda.GetStartedFunctions_Helper] - -// IScenarioHelper abstracts I/O and wait functions from a scenario so that they -// can be mocked for unit testing. -type IScenarioHelper interface { - Pause(secs int) - CreateDeploymentPackage(sourceFile string, destinationFile string) *bytes.Buffer -} - -// ScenarioHelper lets the caller specify the path to Lambda handler functions. -type ScenarioHelper struct { - HandlerPath string -} - -// Pause waits for the specified number of seconds. -func (helper *ScenarioHelper) Pause(secs int) { - time.Sleep(time.Duration(secs) * time.Second) -} - -// CreateDeploymentPackage creates an AWS Lambda deployment package from a source file. The -// deployment package is stored in .zip format in a bytes.Buffer. The buffer can be -// used to pass a []byte to Lambda when creating the function. -// The specified destinationFile is the name to give the file when it's deployed to Lambda. -func (helper *ScenarioHelper) CreateDeploymentPackage(sourceFile string, destinationFile string) *bytes.Buffer { - var err error - buffer := &bytes.Buffer{} - writer := zip.NewWriter(buffer) - zFile, err := writer.Create(destinationFile) - if err != nil { - log.Panicf("Couldn't create destination archive %v. Here's why: %v\n", destinationFile, err) - } - sourceBody, err := os.ReadFile(fmt.Sprintf("%v/%v", helper.HandlerPath, sourceFile)) - if err != nil { - log.Panicf("Couldn't read handler source file %v. Here's why: %v\n", - sourceFile, err) - } else { - _, err = zFile.Write(sourceBody) - if err != nil { - log.Panicf("Couldn't write handler %v to zip archive. Here's why: %v\n", - sourceFile, err) - } - } - err = writer.Close() - if err != nil { - log.Panicf("Couldn't close zip writer. Here's why: %v\n", err) - } - return buffer -} - -// snippet-end:[gov2.lambda.GetStartedFunctions_Helper] - -// snippet-start:[gov2.lambda.Scenario_GetStartedFunctions] - // GetStartedFunctionsScenario shows you how to use AWS Lambda to perform the following // actions: // @@ -335,4 +284,51 @@ func (scenario GetStartedFunctionsScenario) Cleanup(ctx context.Context, role *i } } +// IScenarioHelper abstracts I/O and wait functions from a scenario so that they +// can be mocked for unit testing. +type IScenarioHelper interface { + Pause(secs int) + CreateDeploymentPackage(sourceFile string, destinationFile string) *bytes.Buffer +} + +// ScenarioHelper lets the caller specify the path to Lambda handler functions. +type ScenarioHelper struct { + HandlerPath string +} + +// Pause waits for the specified number of seconds. +func (helper *ScenarioHelper) Pause(secs int) { + time.Sleep(time.Duration(secs) * time.Second) +} + +// CreateDeploymentPackage creates an AWS Lambda deployment package from a source file. The +// deployment package is stored in .zip format in a bytes.Buffer. The buffer can be +// used to pass a []byte to Lambda when creating the function. +// The specified destinationFile is the name to give the file when it's deployed to Lambda. +func (helper *ScenarioHelper) CreateDeploymentPackage(sourceFile string, destinationFile string) *bytes.Buffer { + var err error + buffer := &bytes.Buffer{} + writer := zip.NewWriter(buffer) + zFile, err := writer.Create(destinationFile) + if err != nil { + log.Panicf("Couldn't create destination archive %v. Here's why: %v\n", destinationFile, err) + } + sourceBody, err := os.ReadFile(fmt.Sprintf("%v/%v", helper.HandlerPath, sourceFile)) + if err != nil { + log.Panicf("Couldn't read handler source file %v. Here's why: %v\n", + sourceFile, err) + } else { + _, err = zFile.Write(sourceBody) + if err != nil { + log.Panicf("Couldn't write handler %v to zip archive. Here's why: %v\n", + sourceFile, err) + } + } + err = writer.Close() + if err != nil { + log.Panicf("Couldn't close zip writer. Here's why: %v\n", err) + } + return buffer +} + // snippet-end:[gov2.lambda.Scenario_GetStartedFunctions] diff --git a/gov2/lambda/scenarios/scenario_get_started_functions_test.go b/gov2/lambda/scenarios/scenario_get_started_functions_test.go index 3ecc4d91be0..fdff65ddede 100644 --- a/gov2/lambda/scenarios/scenario_get_started_functions_test.go +++ b/gov2/lambda/scenarios/scenario_get_started_functions_test.go @@ -86,7 +86,7 @@ func (scenTest *GetStartedFunctionsScenarioTest) SetupDataAndStubs() []testtools // CreateFunction stubList = append(stubList, stubs.StubCreateFunction(funcName, codeBytes, roleArn, - fmt.Sprintf("%v.lambda_handler", funcName), true, lambdatypes.RuntimePython38, + fmt.Sprintf("%v.lambda_handler", funcName), true, lambdatypes.RuntimePython39, lambdatypes.StateActive, nil)) stubList = append(stubList, stubs.StubGetFunction(funcName, lambdatypes.StateActive, lambdatypes.LastUpdateStatusSuccessful, nil)) diff --git a/gov2/rds/actions/instances.go b/gov2/rds/actions/instances.go index 04aeab1041a..9469f4680cb 100644 --- a/gov2/rds/actions/instances.go +++ b/gov2/rds/actions/instances.go @@ -3,6 +3,9 @@ package actions +// snippet-start:[gov2.rds.DbInstances.complete] +// snippet-start:[gov2.rds.DbInstances.struct] + import ( "context" "errors" @@ -13,9 +16,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/rds/types" ) -// snippet-start:[gov2.rds.DbInstances.complete] -// snippet-start:[gov2.rds.DbInstances.struct] - type DbInstances struct { RdsClient *rds.Client } diff --git a/gov2/rds/scenarios/get_started_instances.go b/gov2/rds/scenarios/get_started_instances.go index 062c43b0bef..895714b16a2 100644 --- a/gov2/rds/scenarios/get_started_instances.go +++ b/gov2/rds/scenarios/get_started_instances.go @@ -3,6 +3,8 @@ package scenarios +// snippet-start:[gov2.rds.Scenario_GetStartedInstances] + import ( "context" "fmt" @@ -20,26 +22,6 @@ import ( "github.com/google/uuid" ) -// IScenarioHelper abstracts the function from a scenario so that it -// can be mocked for unit testing. -type IScenarioHelper interface { - Pause(secs int) - UniqueId() string -} -type ScenarioHelper struct{} - -// Pause waits for the specified number of seconds. -func (helper ScenarioHelper) Pause(secs int) { - time.Sleep(time.Duration(secs) * time.Second) -} - -// UniqueId returns a new UUID. -func (helper ScenarioHelper) UniqueId() string { - return uuid.New().String() -} - -// snippet-start:[gov2.rds.Scenario_GetStartedInstances] - // GetStartedInstances is an interactive example that shows you how to use the AWS SDK for Go // with Amazon Relation Database Service (Amazon RDS) to do the following: // @@ -339,4 +321,22 @@ func (scenario GetStartedInstances) Cleanup( } } +// IScenarioHelper abstracts the function from a scenario so that it +// can be mocked for unit testing. +type IScenarioHelper interface { + Pause(secs int) + UniqueId() string +} +type ScenarioHelper struct{} + +// Pause waits for the specified number of seconds. +func (helper ScenarioHelper) Pause(secs int) { + time.Sleep(time.Duration(secs) * time.Second) +} + +// UniqueId returns a new UUID. +func (helper ScenarioHelper) UniqueId() string { + return uuid.New().String() +} + // snippet-end:[gov2.rds.Scenario_GetStartedInstances] diff --git a/gov2/redshift/actions/redshiftdata_actions.go b/gov2/redshift/actions/redshiftdata_actions.go index b70a6c1e04b..63eea98c8d3 100644 --- a/gov2/redshift/actions/redshiftdata_actions.go +++ b/gov2/redshift/actions/redshiftdata_actions.go @@ -3,6 +3,8 @@ package actions +// snippet-start:[gov2.redshift.DataActionsStruct] + import ( "context" "errors" @@ -13,8 +15,6 @@ import ( "log" ) -// snippet-start:[gov2.redshift.DataActionsStruct] - // RedshiftDataActions wraps RedshiftData actions. type RedshiftDataActions struct { RedshiftDataClient *redshiftdata.Client diff --git a/gov2/s3/scenarios/scenario_presigning.go b/gov2/s3/scenarios/scenario_presigning.go index e63e903ce9d..6cb379f4c58 100644 --- a/gov2/s3/scenarios/scenario_presigning.go +++ b/gov2/s3/scenarios/scenario_presigning.go @@ -3,7 +3,7 @@ package scenarios -// snippet-start:[gov2.s3.IHttpRequester.helper] +// snippet-start:[gov2.s3.Scenario_Presigning.imports] import ( "bytes" @@ -21,6 +21,9 @@ import ( "github.com/awsdocs/aws-doc-sdk-examples/gov2/s3/actions" ) +// snippet-end:[gov2.s3.Scenario_Presigning.imports] +// snippet-start:[gov2.s3.IHttpRequester.helper] + // IHttpRequester abstracts HTTP requests into an interface so it can be mocked during // unit testing. type IHttpRequester interface { diff --git a/gov2/workflows/topics_and_queues/actions/sns_actions.go b/gov2/workflows/topics_and_queues/actions/sns_actions.go index dba7ed9dc82..a4043c93688 100644 --- a/gov2/workflows/topics_and_queues/actions/sns_actions.go +++ b/gov2/workflows/topics_and_queues/actions/sns_actions.go @@ -3,6 +3,9 @@ package actions +// snippet-start:[gov2.sns.SnsActions.complete] +// snippet-start:[gov2.sns.SnsActions.struct] + import ( "context" "encoding/json" @@ -13,9 +16,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/sns/types" ) -// snippet-start:[gov2.sns.SnsActions.complete] -// snippet-start:[gov2.sns.SnsActions.struct] - // SnsActions encapsulates the Amazon Simple Notification Service (Amazon SNS) actions // used in the examples. type SnsActions struct { diff --git a/gov2/workflows/topics_and_queues/actions/sqs_actions.go b/gov2/workflows/topics_and_queues/actions/sqs_actions.go index dc6a9016e5d..114237b0185 100644 --- a/gov2/workflows/topics_and_queues/actions/sqs_actions.go +++ b/gov2/workflows/topics_and_queues/actions/sqs_actions.go @@ -3,6 +3,9 @@ package actions +// snippet-start:[gov2.sqs.SqsActions.complete] +// snippet-start:[gov2.sqs.SqsActions.struct] + import ( "context" "encoding/json" @@ -14,9 +17,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -// snippet-start:[gov2.sqs.SqsActions.complete] -// snippet-start:[gov2.sqs.SqsActions.struct] - // SqsActions encapsulates the Amazon Simple Queue Service (Amazon SQS) actions // used in the examples. type SqsActions struct { diff --git a/gov2/workflows/topics_and_queues/workflows/resources.go b/gov2/workflows/topics_and_queues/workflows/resources.go index b473b73b634..476effa8a44 100644 --- a/gov2/workflows/topics_and_queues/workflows/resources.go +++ b/gov2/workflows/topics_and_queues/workflows/resources.go @@ -3,6 +3,8 @@ package workflows +// snippet-start:[gov2.workflows.TopicsAndQueues.Resources.complete] + import ( "context" "fmt" @@ -45,3 +47,5 @@ func (resources Resources) Cleanup(ctx context.Context) { } } } + +// snippet-end:[gov2.workflows.TopicsAndQueues.Resources.complete] diff --git a/gov2/workflows/topics_and_queues/workflows/scenario_topics_and_queues.go b/gov2/workflows/topics_and_queues/workflows/scenario_topics_and_queues.go index c28536c8b2f..a55bbfd6a64 100644 --- a/gov2/workflows/topics_and_queues/workflows/scenario_topics_and_queues.go +++ b/gov2/workflows/topics_and_queues/workflows/scenario_topics_and_queues.go @@ -3,6 +3,8 @@ package workflows +// snippet-start:[gov2.workflows.TopicsAndQueues] + import ( "context" "encoding/json" @@ -18,8 +20,6 @@ import ( "github.com/awsdocs/aws-doc-sdk-examples/gov2/demotools" ) -// snippet-start:[gov2.workflows.TopicsAndQueues] - const FIFO_SUFFIX = ".fifo" const TONE_KEY = "tone" diff --git a/gov2/workflows/user_pools_and_lambda_triggers/actions/cloud_formation_actions.go b/gov2/workflows/user_pools_and_lambda_triggers/actions/cloud_formation_actions.go index 78cd90443e8..769bacbb985 100644 --- a/gov2/workflows/user_pools_and_lambda_triggers/actions/cloud_formation_actions.go +++ b/gov2/workflows/user_pools_and_lambda_triggers/actions/cloud_formation_actions.go @@ -3,6 +3,8 @@ package actions +// snippet-start:[gov2.cloudformation.CloudFormationActions.complete] + import ( "context" "log" @@ -11,8 +13,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/cloudformation" ) -// snippet-start:[gov2.cloudformation.CloudFormationActions.complete] - // StackOutputs defines a map of outputs from a specific stack. type StackOutputs map[string]string diff --git a/gov2/workflows/user_pools_and_lambda_triggers/actions/cloudwatch_logs_actions.go b/gov2/workflows/user_pools_and_lambda_triggers/actions/cloudwatch_logs_actions.go index 08b233bb624..86578acd75e 100644 --- a/gov2/workflows/user_pools_and_lambda_triggers/actions/cloudwatch_logs_actions.go +++ b/gov2/workflows/user_pools_and_lambda_triggers/actions/cloudwatch_logs_actions.go @@ -3,6 +3,8 @@ package actions +// snippet-start:[gov2.cloudwatch-logs.CloudWatchLogsActions.complete] + import ( "context" "fmt" @@ -13,8 +15,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types" ) -// snippet-start:[gov2.cloudwatch-logs.CloudWatchLogsActions.complete] - type CloudWatchLogsActions struct { CwlClient *cloudwatchlogs.Client } diff --git a/gov2/workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go b/gov2/workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go index 58e08741e99..6569bc9f5af 100644 --- a/gov2/workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go +++ b/gov2/workflows/user_pools_and_lambda_triggers/actions/cognito_actions.go @@ -3,6 +3,9 @@ package actions +// snippet-start:[gov2.cognito-identity-provider.CognitoActions.complete] +// snippet-start:[gov2.cognito-identity-provider.CognitoActions.struct] + import ( "context" "errors" @@ -13,10 +16,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider/types" ) -// snippet-start:[gov2.cognito-identity-provider.CognitoActions.complete] - -// snippet-start:[gov2.cognito-identity-provider.CognitoActions.struct] - type CognitoActions struct { CognitoClient *cognitoidentityprovider.Client } diff --git a/gov2/workflows/user_pools_and_lambda_triggers/actions/dynamo_actions.go b/gov2/workflows/user_pools_and_lambda_triggers/actions/dynamo_actions.go index 09fe45c9554..e0591541f18 100644 --- a/gov2/workflows/user_pools_and_lambda_triggers/actions/dynamo_actions.go +++ b/gov2/workflows/user_pools_and_lambda_triggers/actions/dynamo_actions.go @@ -3,6 +3,8 @@ package actions +// snippet-start:[gov2.dynamodb.DynamoActions.complete] + import ( "context" "fmt" @@ -14,8 +16,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) -// snippet-start:[gov2.dynamodb.DynamoActions.complete] - // DynamoActions encapsulates the Amazon Simple Notification Service (Amazon SNS) actions // used in the examples. type DynamoActions struct { diff --git a/gov2/workflows/user_pools_and_lambda_triggers/handlers/activity_log/activity_log_handler.go b/gov2/workflows/user_pools_and_lambda_triggers/handlers/activity_log/activity_log_handler.go index d81649749a5..2529ccbc79a 100644 --- a/gov2/workflows/user_pools_and_lambda_triggers/handlers/activity_log/activity_log_handler.go +++ b/gov2/workflows/user_pools_and_lambda_triggers/handlers/activity_log/activity_log_handler.go @@ -3,6 +3,8 @@ package main +// snippet-start:[gov2.lambda.ActivityLogHandler] + import ( "context" "fmt" @@ -19,8 +21,6 @@ import ( dynamodbtypes "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) -// snippet-start:[gov2.lambda.ActivityLogHandler] - const TABLE_NAME = "TABLE_NAME" // LoginInfo defines structured login data that can be marshalled to a DynamoDB format. diff --git a/gov2/workflows/user_pools_and_lambda_triggers/handlers/auto_confirm/auto_confirm_handler.go b/gov2/workflows/user_pools_and_lambda_triggers/handlers/auto_confirm/auto_confirm_handler.go index c451709e0fa..8c3bdd4b138 100644 --- a/gov2/workflows/user_pools_and_lambda_triggers/handlers/auto_confirm/auto_confirm_handler.go +++ b/gov2/workflows/user_pools_and_lambda_triggers/handlers/auto_confirm/auto_confirm_handler.go @@ -3,6 +3,8 @@ package main +// snippet-start:[gov2.lambda.AutoConfirmHandler] + import ( "context" "log" @@ -17,8 +19,6 @@ import ( dynamodbtypes "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) -// snippet-start:[gov2.lambda.AutoConfirmHandler] - const TABLE_NAME = "TABLE_NAME" // UserInfo defines structured user data that can be marshalled to a DynamoDB format. diff --git a/gov2/workflows/user_pools_and_lambda_triggers/handlers/migrate_user/migrate_user_handler.go b/gov2/workflows/user_pools_and_lambda_triggers/handlers/migrate_user/migrate_user_handler.go index 38684015d80..a01a3fd422e 100644 --- a/gov2/workflows/user_pools_and_lambda_triggers/handlers/migrate_user/migrate_user_handler.go +++ b/gov2/workflows/user_pools_and_lambda_triggers/handlers/migrate_user/migrate_user_handler.go @@ -3,6 +3,8 @@ package main +// snippet-start:[gov2.lambda.MigrateUserHandler] + import ( "context" "log" @@ -17,8 +19,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb" ) -// snippet-start:[gov2.lambda.MigrateUserHandler] - const TABLE_NAME = "TABLE_NAME" // UserInfo defines structured user data that can be marshalled to a DynamoDB format. diff --git a/gov2/workflows/user_pools_and_lambda_triggers/workflows/resources.go b/gov2/workflows/user_pools_and_lambda_triggers/workflows/resources.go index 76ac23af69a..4bbcc9bd9ac 100644 --- a/gov2/workflows/user_pools_and_lambda_triggers/workflows/resources.go +++ b/gov2/workflows/user_pools_and_lambda_triggers/workflows/resources.go @@ -3,6 +3,8 @@ package workflows +// snippet-start:[gov2.cognito-identity-provider.Resources.complete] + import ( "context" "log" @@ -11,8 +13,6 @@ import ( "github.com/awsdocs/aws-doc-sdk-examples/gov2/demotools" ) -// snippet-start:[gov2.cognito-identity-provider.Resources.complete] - // Resources keeps track of AWS resources created during an example and handles // cleanup when the example finishes. type Resources struct { diff --git a/gov2/workflows/user_pools_and_lambda_triggers/workflows/scenario_activity_log.go b/gov2/workflows/user_pools_and_lambda_triggers/workflows/scenario_activity_log.go index 403d0cb8354..e6eabdd8bdd 100644 --- a/gov2/workflows/user_pools_and_lambda_triggers/workflows/scenario_activity_log.go +++ b/gov2/workflows/user_pools_and_lambda_triggers/workflows/scenario_activity_log.go @@ -3,6 +3,8 @@ package workflows +// snippet-start:[gov2.workflows.PoolsAndTriggers.ActivityLog] + import ( "context" "errors" @@ -16,8 +18,6 @@ import ( "github.com/awsdocs/aws-doc-sdk-examples/gov2/demotools" ) -// snippet-start:[gov2.workflows.PoolsAndTriggers.ActivityLog] - // ActivityLog separates the steps of this scenario into individual functions so that // they are simpler to read and understand. type ActivityLog struct { diff --git a/gov2/workflows/user_pools_and_lambda_triggers/workflows/scenario_auto_confirm_trusted_accounts.go b/gov2/workflows/user_pools_and_lambda_triggers/workflows/scenario_auto_confirm_trusted_accounts.go index bf2c8a8b46d..942a7f0fbf1 100644 --- a/gov2/workflows/user_pools_and_lambda_triggers/workflows/scenario_auto_confirm_trusted_accounts.go +++ b/gov2/workflows/user_pools_and_lambda_triggers/workflows/scenario_auto_confirm_trusted_accounts.go @@ -3,6 +3,8 @@ package workflows +// snippet-start:[gov2.workflows.PoolsAndTriggers.AutoConfirm] + import ( "context" "errors" @@ -16,8 +18,6 @@ import ( "github.com/awsdocs/aws-doc-sdk-examples/gov2/demotools" ) -// snippet-start:[gov2.workflows.PoolsAndTriggers.AutoConfirm] - // AutoConfirm separates the steps of this scenario into individual functions so that // they are simpler to read and understand. type AutoConfirm struct { diff --git a/gov2/workflows/user_pools_and_lambda_triggers/workflows/scenario_common.go b/gov2/workflows/user_pools_and_lambda_triggers/workflows/scenario_common.go index 6dbc76fc937..05db66b373e 100644 --- a/gov2/workflows/user_pools_and_lambda_triggers/workflows/scenario_common.go +++ b/gov2/workflows/user_pools_and_lambda_triggers/workflows/scenario_common.go @@ -3,6 +3,8 @@ package workflows +// snippet-start:[gov2.workflows.PoolsAndTriggers.ScenarioHelper] + import ( "context" "log" @@ -17,8 +19,6 @@ import ( "github.com/awsdocs/aws-doc-sdk-examples/gov2/demotools" ) -// snippet-start:[gov2.workflows.PoolsAndTriggers.ScenarioHelper] - // IScenarioHelper defines common functions used by the workflows in this example. type IScenarioHelper interface { Pause(secs int)