aws

package
v0.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2025 License: GPL-3.0 Imports: 56 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertS3BucketNotificationExists

func AssertS3BucketNotificationExists(t testing.TestingT, region string, bucketName string)

AssertS3BucketNotificationExists checks if the given S3 bucket has a notification configuration and returns an error if it does not.

func AssertS3BucketNotificationExistsE

func AssertS3BucketNotificationExistsE(t testing.TestingT, region string, bucketName string) error

AssertS3BucketVersioningExistsE checks if the given S3 bucket has a notification configuration and returns an error if it does not.

func ChangeMessageVisibility

func ChangeMessageVisibility(t testing.TestingT, awsRegion string, queueURL string, receipt string, timeoutSeconds int32)

func ChangeMessageVisibilityE

func ChangeMessageVisibilityE(t testing.TestingT, awsRegion string, queueURL string, receipt string, timeoutSeconds int32) error

func DeployUsingTerraform

func DeployUsingTerraform(t *testing.T, workingDir string, additionalRetryableErrors map[string]string)

func DescribeSfnExecution

func DescribeSfnExecution(t testing.TestingT, awsRegion string, executionArn string) *sfn.DescribeExecutionOutput

DescribeSfnExecution returns the description of the specified execution. This will fail the test if there is an error.

func DescribeSfnExecutionE

func DescribeSfnExecutionE(t testing.TestingT, awsRegion string, executionArn string) (*sfn.DescribeExecutionOutput, error)

DescribeSfnExecutionE returns the description of the specified execution.

func DescribeStream

func DescribeStream(t testing.TestingT, region string, streamName string) *types.StreamDescription

DescribeStream returns the description of a Kinesis stream.

func DescribeStreamE

func DescribeStreamE(t testing.TestingT, region string, streamName string) (*types.StreamDescription, error)

DescribeStreamE returns the description of a Kinesis stream.

func FilterLogEvents

func FilterLogEvents(t testing.TestingT, awsRegion string, logGroupName string) []string

GetCloudWatchLogEntries returns the CloudWatch log messages in the given region for the given log stream and log group.

func FilterLogEventsE

func FilterLogEventsE(t testing.TestingT, awsRegion string, logGroupName string) ([]string, error)

GetCloudWatchLogEntriesE returns the CloudWatch log messages in the given region for the given log stream and log group.

func ForwardingLogger

func ForwardingLogger(t *testing.T, targetLogger *loggers.Logger) *zap.Logger

ForwardingLogger returns a zap logger that forwards all log messages to terratestLogger

func GetAcmCertificateStatus

func GetAcmCertificateStatus(t testing.TestingT, awsRegion string, certArn string) types.CertificateStatus

Get Certificate Status

func GetAcmCertificateStatusE

func GetAcmCertificateStatusE(t testing.TestingT, awsRegion string, certArn string) (types.CertificateStatus, error)

GetAcmCertificateStatusE gets the ACM certificate status for the given certificate ARN in the given region.

func GetAlarmE

func GetAlarmE(t testing.TestingT, awsRegion string, alarmName string, alarmType types.AlarmType) (*cloudwatch.DescribeAlarmsOutput, error)

GetMetricAlarmE returns the details of the specified alarm.

func GetCompositeAlarm

func GetCompositeAlarm(t testing.TestingT, awsRegion string, alarmName string) *types.CompositeAlarm

GetMetricAlarm returns the details of the specified metric alarm.

func GetCompositeAlarmE

func GetCompositeAlarmE(t testing.TestingT, awsRegion string, alarmName string) (*types.CompositeAlarm, error)

GetMetricAlarmE returns the details of the specified alarm.

func GetDashboardBody

func GetDashboardBody(t testing.TestingT, awsRegion string, dashboardName string) *string

GetDashboardBody returns the body of the specified dashboard.

func GetDashboardBodyE

func GetDashboardBodyE(t testing.TestingT, awsRegion string, dashboardName string) (*string, error)

GetDashboardBodyE returns the body of the specified dashboard.

func GetDataProtectionPolicyDocument

func GetDataProtectionPolicyDocument(t testing.TestingT, awsRegion string, logGroupName string) string

GetDataProtectionPolicyDocument returns the policy of the specified log group data protection policy.

func GetDataProtectionPolicyDocumentE

func GetDataProtectionPolicyDocumentE(t testing.TestingT, awsRegion string, logGroupName string) (*string, error)

GetDataProtectionPolicyDocumentE returns the details of the specified log group data protection policy.

func GetDistributionE added in v0.0.10

func GetDistributionE(t testing.TestingT, region string, distributionId string) (*types.Distribution, error)

GetDistributionE returns the configuration of a CloudFront Distribution

func GetKmsAlias

func GetKmsAlias(t testing.TestingT, region string, aliasName string) types.AliasListEntry

GetKmsAlias gets the KMS alias or panic if not found.

func GetKmsAliasE

func GetKmsAliasE(t testing.TestingT, region string, aliasName string) (*types.AliasListEntry, error)

GetKmsAliasE gets the KMS alias

func GetKmsKey

func GetKmsKey(t testing.TestingT, region string, cmkID string) *types.KeyMetadata

GetKmsKey gets the KMS key

func GetKmsKeyE

func GetKmsKeyE(t testing.TestingT, region string, cmkID string) (*types.KeyMetadata, error)

GetKmsKeyE gets the metadata for KMS Customer Master Key (CMK) in the given region with the given ID. The ID can be an alias, such as as "alias/my-cmk".

func GetKmsKeyPolicy

func GetKmsKeyPolicy(t testing.TestingT, region string, cmkID string) string

GetKmsKeyPolicy gets the key policy document in JSON format.

func GetKmsKeyPolicyE

func GetKmsKeyPolicyE(t testing.TestingT, region string, cmkID string) (*string, error)

GetKmsKeyPolicyE gets the key policy document in JSON format.

func GetLogGroup

func GetLogGroup(t testing.TestingT, awsRegion string, logGroupName string) *logtypes.LogGroup

GetLogGroup returns the details of the specified log group.

func GetLogGroupE

func GetLogGroupE(t testing.TestingT, awsRegion string, logGroupName string) (*logtypes.LogGroup, error)

GetLogGroupE returns the details of the specified log group.

func GetMetricAlarm

func GetMetricAlarm(t testing.TestingT, awsRegion string, alarmName string) *types.MetricAlarm

GetMetricAlarm returns the details of the specified alarm.

func GetMetricAlarmE

func GetMetricAlarmE(t testing.TestingT, awsRegion string, alarmName string) (*types.MetricAlarm, error)

GetMetricAlarmE returns the details of the specified composite alarm.

func GetS3BucketNotificationE

func GetS3BucketNotificationE(t testing.TestingT, region string, bucketName string) (*s3.GetBucketNotificationConfigurationOutput, error)

GetS3BucketNotificationE fetches the given bucket's notification configuration

func GetStreamResourcePolicy

func GetStreamResourcePolicy(t testing.TestingT, region string, streamArn string) string

GetStreamResourcePolicy returns the Kinesis stream resource policy as a JSON string

func GetStreamResourcePolicyE

func GetStreamResourcePolicyE(t testing.TestingT, region string, streamArn string) (*string, error)

GetStreamResourcePolicy returns the Kinesis stream resource policy as a JSON string or an error

func InvokeFunctionWithParams

func InvokeFunctionWithParams(t testing.TestingT, region, functionName string, input *LambdaOptions) *terratestaws.LambdaOutput

InvokeFunctionWithParams invokes a lambda function using parameters supplied in the LambdaOptions struct and returns values in a LambdaOutput struct. Checks for failure using "require".

func InvokeFunctionWithParamsE

func InvokeFunctionWithParamsE(t testing.TestingT, region, functionName string, input *LambdaOptions) (*terratestaws.LambdaOutput, error)

InvokeFunctionWithParamsE invokes a lambda function using parameters supplied in the LambdaOptions struct. Returns the status code and payload in a LambdaOutput struct and the error. A non-nil error will either reflect a problem with the parameters supplied to this function or an error returned by the Lambda.

func LoadOutputAttribute

func LoadOutputAttribute(t *testing.T, terraformOptions *terraform.Options, key, attribute string) string

LoadOutputAttribute loads the attribute of a output key from Terraform outputs and ensures it is not empty.

func LoadSynthDependencies

func LoadSynthDependencies(t *testing.T, testFolder string, dependencies *map[string]string)

LoadSynthDependencies reads a saved map of dependencies at synth time to the given path.

func NewCloudFrontclient

func NewCloudFrontclient(t testing.TestingT) *cloudfront.Client

NewCloudFrontclient returns a client for CloudFront. This will fail the test and stop execution if there is an error.

func NewCloudFrontclientE

func NewCloudFrontclientE(t testing.TestingT) (*cloudfront.Client, error)

NewCloudFrontclientE returns a client for CloudFront.

func NewCloudWatchClient

func NewCloudWatchClient(t testing.TestingT, region string) *cloudwatch.Client

NewCloudWatchEventsClient creates a new CloudWatch Events client.

func NewCloudWatchClientE

func NewCloudWatchClientE(t testing.TestingT, region string) (*cloudwatch.Client, error)

NewCloudWatchEventsClientE creates a new CloudWatch Logs client.

func NewCloudWatchEventsClient

func NewCloudWatchEventsClient(t testing.TestingT, region string) *cloudwatchevents.Client

NewCloudWatchEventsClient creates a new CloudWatch Events client.

func NewCloudWatchEventsClientE

func NewCloudWatchEventsClientE(t testing.TestingT, region string) (*cloudwatchevents.Client, error)

NewCloudWatchEventsClientE creates a new CloudWatch Logs client.

func NewEventBridgeClient

func NewEventBridgeClient(t testing.TestingT, region string) *eventbridge.Client

NewEventBridgeClient creates an RDS client.

func NewEventBridgeClientE

func NewEventBridgeClientE(t testing.TestingT, region string) (*eventbridge.Client, error)

NewEventBridgeClientE creates an RDS client.

func NewKinesisClient

func NewKinesisClient(t testing.TestingT, region string) *kinesis.Client

NewKinesisClient creates a kinesis client.

func NewKinesisClientE

func NewKinesisClientE(t testing.TestingT, region string) (*kinesis.Client, error)

NewKinesisClientE creates a kinesis client.

func NewSfnclient

func NewSfnclient(t testing.TestingT, awsRegion string) *sfn.Client

NewSfnclient returns a client for StepFunctions. This will fail the test if there is an error.

func NewSfnclientE

func NewSfnclientE(t testing.TestingT, awsRegion string) (*sfn.Client, error)

NewSfnclientE returns a client for StepFunctions.

func PrettyPrintBeforeAfter

func PrettyPrintBeforeAfter(before interface{}, after interface{}) (string, error)

func PrettyPrintResourceChange

func PrettyPrintResourceChange(rc *tfjson.ResourceChange) (string, error)

func PutEvents

func PutEvents(t testing.TestingT, region string, entries []types.PutEventsRequestEntry)

PutEvents sends custom events to Amazon EventBridge so that they can be matched to rules.

func PutEventsE

func PutEventsE(t testing.TestingT, region string, entries []types.PutEventsRequestEntry) error

PutEventsE sends custom events to Amazon EventBridge so that they can be matched to rules.

func SaveSynthDependencies

func SaveSynthDependencies(t *testing.T, testFolder string, dependencies *map[string]string)

SaveSynthDependencies serializes and saves map of dependencies at test time to the given path.

func SendMessageFifoToQueueWithDeduplicationId

func SendMessageFifoToQueueWithDeduplicationId(t testing.TestingT, awsRegion string, queueURL string, message string, messageGroupID string, messageDeduplicationId string)

SendMessageToFifoQueue sends the given message to the FIFO SQS queue with the given URL.

func SendMessageToFifoQueueWithDeduplicationIdE

func SendMessageToFifoQueueWithDeduplicationIdE(t testing.TestingT, awsRegion string, queueURL string, message string, messageGroupID string, messageDeduplicationId string) error

SendMessageToFifoQueueWithDeduplicationIdE sends the given message to the FIFO SQS queue with the given URL.

func StartSfnExecution

func StartSfnExecution(t testing.TestingT, awsRegion string, stateMachineArn string, input interface{}) *string

StartSfnExecution starts a new execution of the specified state machine and returns the execution ARN. This will fail the test if there is an error.

func StartSfnExecutionE

func StartSfnExecutionE(t testing.TestingT, awsRegion string, stateMachineArn string, input interface{}) (*string, error)

StartSfnExecutionE starts a new execution of the specified state machine and returns the execution ARN.

func StopSfnExecution

func StopSfnExecution(t testing.TestingT, awsRegion string, executionArn string)

StopSfnExecution stops the specified execution. This will fail the test if there is an error.

func StopSfnExecutionE

func StopSfnExecutionE(t testing.TestingT, awsRegion string, executionArn string) error

StopSfnExecutionE stops the specified execution.

func SynthApp

func SynthApp(t *testing.T, testApp, tfWorkingDir string, env map[string]string, additionalAppDirs ...string)

Synth app relative to the integration namespace

func TestCloudFrontFunction

func TestCloudFrontFunction(t testing.TestingT, name string, stage string, event CloudFrontFunctionEvent, expectedError string, expectedOutput *map[string]interface{}) error

Tests a CloudFront function.

To test a function, you provide an event object that represents an HTTP request or response that your CloudFront distribution could receive in production. CloudFront runs the function, passing it the event object that you provided, and returns the function's result (the modified event object) in the response. The response also contains function logs and error messages, if any exist. For more information about testing functions, see Testing functionsin the Amazon CloudFront Developer Guide.

To test a function, you provide the function's name and stage (DEVELOPMENT or LIVE) along with the event object. To get the function's name and version, you can use ListFunctions and DescribeFunction.

func TestCloudFrontFunctionWithCustomValidation

func TestCloudFrontFunctionWithCustomValidation(t testing.TestingT, name string, stage string, event CloudFrontFunctionEvent, validateResponse responseValidator) error

TestCloudFrontFunctionWithCustomValidation performs a Function test and validate the response. Fails the test if there is an error.

func TestCloudFrontFunctionWithCustomValidationE

func TestCloudFrontFunctionWithCustomValidationE(t testing.TestingT, name string, stage types.FunctionStage, event CloudFrontFunctionEvent, validateResponse responseValidator) error

TestCloudFrontFunctionWithCustomValidationE performs a Function test and validate the response.

func URLDecode

func URLDecode(encoded string) (string, error)

URLDecode decodes a URL-encoded string.

func UndeployUsingTerraform

func UndeployUsingTerraform(t *testing.T, workingDir string)

func UploadS3File

func UploadS3File(t testing.TestingT, awsRegion string, s3BucketName string, key string, body string)

UploadS3File uploads a file to the given S3 bucket with the given key and body and fails the test if there is any error.

func UploadS3FileE

func UploadS3FileE(t testing.TestingT, awsRegion string, s3BucketName string, key string, body string) error

UploadS3FileE uploads a file to the given S3 bucket with the given key and body and returns an error if there is any.

func WaitForCertificateIssued

func WaitForCertificateIssued(
	t testing.TestingT,
	certArn string,
	region string,
	maxRetries int,
	sleepBetweenRetries time.Duration,
)

WaitForCertificateIssued waits for the certificate to be issued

func WaitForCertificateIssuedE

func WaitForCertificateIssuedE(
	t testing.TestingT,
	certArn string,
	region string,
	maxRetries int,
	sleepBetweenRetries time.Duration,
) error

WaitForCertificateIssuedE waits for the ACM Certificate to be issued

func WaitForDistributionDeployed added in v0.0.10

func WaitForDistributionDeployed(t testing.TestingT, region string, distributionId string, maxRetries int, sleepBetweenRetries time.Duration)

WaitForDistributionDeployed waits for a CloudFront distribution to be deployed.

func WaitForDistributionStatus added in v0.0.10

func WaitForDistributionStatus(
	t testing.TestingT,
	region string,
	distributionId string,
	status string,
	maxRetries int,
	sleepBetweenRetries time.Duration,
)

WaitForDistributionStatus waits for a CloudFront distribution to have the specified status.

func WaitForDistributionStatusE added in v0.0.10

func WaitForDistributionStatusE(
	t testing.TestingT,
	region string,
	distributionId string,
	status string,
	maxRetries int,
	sleepBetweenRetries time.Duration,
) error

WaitForDistributionStatusE waits for a CloudFront distribution to have the specified status.

func WaitForLogEvents

func WaitForLogEvents(
	t testing.TestingT,
	awsRegion string,
	logGroupName string,
	maxRetries int,
	sleepBetweenRetries time.Duration,
) []string

WaitForLogEvents waits for log events to appear in the given CloudWatch Log group in the given region

func WaitForLogEventsE

func WaitForLogEventsE(
	t testing.TestingT,
	awsRegion string,
	logGroupName string,
	maxRetries int,
	sleepBetweenRetries time.Duration,
) ([]string, error)

WaitForLogEventsE waits for log events to appear in the given CloudWatch Log group in the given region

func WaitForStreamActive

func WaitForStreamActive(
	t testing.TestingT,
	region string,
	streamName string,
	maxRetries int,
	sleepBetweenRetries time.Duration,
)

WaitForStreamActive waits for a Kinesis stream to be active.

func WaitForStreamActiveE

func WaitForStreamActiveE(
	t testing.TestingT,
	region string,
	streamName string,
	maxRetries int,
	sleepBetweenRetries time.Duration,
) error

WaitForStreamActiveE waits for a Kinesis stream to be active.

func WaitForStreamStatus

func WaitForStreamStatus(
	t testing.TestingT,
	region string,
	streamName string,
	status types.StreamStatus,
	maxRetries int,
	sleepBetweenRetries time.Duration,
)

WaitForStreamStatus waits for a Kinesis stream to have the specified status.

func WaitForStreamStatusE

func WaitForStreamStatusE(
	t testing.TestingT,
	region string,
	streamName string,
	status types.StreamStatus,
	maxRetries int,
	sleepBetweenRetries time.Duration,
) error

WaitForStreamStatusE waits for a Kinesis stream to have the specified status.

Types

type ActivityHandler

type ActivityHandler interface {
	// Input returns the input data of the activity.
	Input() interface{}
	// SendSuccess sends a success message to the State Machine.
	SendSuccess(output interface{}) error
	// SendFailure sends a failure message to the State Machine.
	SendFailure(errCode string, cause string) error
	// SendHeartbeat sends a heartbeat message to the State Machine.
	SendHeartbeat() error
}

func GetSfnActivity

func GetSfnActivity(t testing.TestingT, awsRegion string, activityArn string, workerName *string) ActivityHandler

GetSfnActivity for a running Sate Machine. Used by workers to retrieve a task (with the specified activity ARN) which has been scheduled for execution by a running state machine.

func GetSfnActivityE

func GetSfnActivityE(t testing.TestingT, awsRegion string, activityArn string, workerName *string) (ActivityHandler, error)

GetSfnActivityE for a running Sate Machine. Used by workers to retrieve a task (with the specified activity ARN) which has been scheduled for execution by a running state machine.

func NewActivityHandler

func NewActivityHandler(sfnClient *sfn.Client, input interface{}, taskToken *string) ActivityHandler

type AttachedPermissionsBoundary

type AttachedPermissionsBoundary struct {
	PermissionsBoundaryArn  string `json:"permissionsBoundaryArn"`  // The ARN of the policy used to set the permissions boundary for the user or role.
	PermissionsBoundaryType string `json:"permissionsBoundaryType"` // The permissions boundary usage type that indicates what type of IAM resource is used as the permissions boundary for an entity. This data type can only have a value of Policy.
}

type BucketNotificationNotEnabledError

type BucketNotificationNotEnabledError struct {
	// contains filtered or unexported fields
}

BucketNotificationNotEnabledError is returned when the S3 bucket notification is not enabled.

func NewBucketNotificationNotEnabledError

func NewBucketNotificationNotEnabledError(region, bucketName string) BucketNotificationNotEnabledError

func (BucketNotificationNotEnabledError) Error

type CertificateNotIssuedError

type CertificateNotIssuedError struct {
	// contains filtered or unexported fields
}

CertificateNotIssuedError is returned when the ACM Certificate status is not issued.

func NewCertificateNotIssuedError

func NewCertificateNotIssuedError(certArn string, currentStatus acmTypes.CertificateStatus) CertificateNotIssuedError

func (CertificateNotIssuedError) Error

func (err CertificateNotIssuedError) Error() string

type CloudFrontFunctionEvent

type CloudFrontFunctionEvent struct {
	Version  Version   `json:"version"` // The version field contains a string that specifies the version of the CloudFront Functions event object. The current version is 1.0.
	Context  Context   `json:"context"` // The context object contains contextual information about the event
	Viewer   Viewer    `json:"viewer"`
	Request  *Request  `json:"request,omitempty"`
	Response *Response `json:"response,omitempty"`
}

CloudFrontFunctionEvent represents the event object that you provide to test a CloudFront function. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-event-structure.html

func ReadCloudFrontEvent

func ReadCloudFrontEvent(path string) (*CloudFrontFunctionEvent, error)

type CloudFrontFunctionValidationFailed

type CloudFrontFunctionValidationFailed struct {
	FunctionName string
	Failures     error
}

CloudFrontFunctionValidationFailed is an error that occurs if response validation fails.

func (CloudFrontFunctionValidationFailed) Error

type CloudFrontTestFunctionResult

type CloudFrontTestFunctionResult struct {
	Utilization  int // The amount of time that the function took to run as a percentage of the maximum allowed time.
	ErrorMessage *string
	// The event object returned by the function. For more information about the
	// structure of the event object, see [Event object structure]in the Amazon CloudFront Developer Guide.
	//
	// [Event object structure]: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-event-structure.html
	Output map[string]interface{}
	// Contains the log lines that the function wrote (if any) when running the test.
	ExecutionLogs []string
}

func TestCloudFrontFunctionE

func TestCloudFrontFunctionE(t testing.TestingT, name string, stage types.FunctionStage, event CloudFrontFunctionEvent) (*CloudFrontTestFunctionResult, error)

TestCloudFrontFunctionE performs a Function test and validates the response.

type CloudwatchEventsRuleInfo

type CloudwatchEventsRuleInfo struct {
	Name               string               // The name of the rule.
	Description        string               // The description of the rule.
	State              eventtypes.RuleState // Specifies whether the rule is enabled or disabled.
	EventPattern       string               // The event pattern.
	ScheduleExpression string               // The scheduling expression. For example, "cron(0 20 * * ? *)", "rate(5 minutes)".
}

func DescribeEventRule

func DescribeEventRule(t testing.TestingT, awsRegion string, ruleName string) *CloudwatchEventsRuleInfo

DescribeEventRule returns the details of the specified rule.

func DescribeEventRuleE

func DescribeEventRuleE(t testing.TestingT, awsRegion string, ruleName string) (*CloudwatchEventsRuleInfo, error)

DescribeEventRuleE returns the details of the specified rule.

type Context

type Context struct {
	DistributionDomainName string `json:"distributionDomainName"` // The CloudFront domain name (for example, d111111abcdef8.cloudfront.net) of the distribution that's associated with the event.
	DistributionID         string `json:"distributionId"`
	EventType              string `json:"eventType"`
	RequestID              string `json:"requestId"`
}

type ForwardingCore

type ForwardingCore struct {
	zapcore.Core
	// contains filtered or unexported fields
}

a simple Zap Logger which forwards all log messages to terratestLogger

func (*ForwardingCore) Check

func (*ForwardingCore) Write

func (fc *ForwardingCore) Write(entry zapcore.Entry, fields []zapcore.Field) error

type IamManagedPolicyNotFoundError

type IamManagedPolicyNotFoundError struct {
	// contains filtered or unexported fields
}

IamManagedPolicyNotFoundError is returned when the IAM managed policy is not found.

func NewIamManagedPolicyNotFoundError

func NewIamManagedPolicyNotFoundError(policyArn string) IamManagedPolicyNotFoundError

func (IamManagedPolicyNotFoundError) Error

type IamRoleNotFoundError

type IamRoleNotFoundError struct {
	// contains filtered or unexported fields
}

IamRoleNotFoundError is returned when the IAM role is not found.

func NewIamRoleNotFoundError

func NewIamRoleNotFoundError(roleName string) IamRoleNotFoundError

func (IamRoleNotFoundError) Error

func (err IamRoleNotFoundError) Error() string

type InlinePolicy

type InlinePolicy struct {
	PolicyDocument string `json:"policyDocument"` // The policy document.
	PolicyName     string `json:"policyName"`     // The name of the policy.
}

Contains decoded inline document and policy name

type InvocationTypeOption

type InvocationTypeOption string

TODO: PR "Event" Invocation Type support to terratest upstream ref: https://github.com/gruntwork-io/terratest/pull/817

const (
	InvocationTypeRequestResponse InvocationTypeOption = "RequestResponse"
	InvocationTypeDryRun          InvocationTypeOption = "DryRun"
	InvocationTypeEvent           InvocationTypeOption = "Event"
)

func (*InvocationTypeOption) Value

func (itype *InvocationTypeOption) Value() (string, error)

type LambdaOptions

type LambdaOptions struct {
	// InvocationType can be one of InvocationTypeOption values:
	//    * InvocationTypeRequestResponse (default) - Invoke the function
	//      synchronously.  Keep the connection open until the function
	//      returns a response or times out.
	//    * InvocationTypeDryRun - Validate parameter values and verify
	//      that the user or role has permission to invoke the function.
	InvocationType *InvocationTypeOption

	// Lambda function input; will be converted to JSON.
	Payload interface{}
}

LambdaOptions contains additional parameters for InvokeFunctionWithParams(). It contains a subset of the fields found in the lambda.InvokeInput struct.

type ManagedPolicy

type ManagedPolicy struct {
	Arn                           string      `json:"arn"`                           // The Amazon Resource Name (ARN).
	PolicyDocument                string      `json:"policyDocument"`                // The policy document.
	AttachmentCount               int32       `json:"attachmentCount"`               // The number of entities (users, groups, and roles) that the policy is attached to.
	CreateDate                    time.Time   `json:"createDate"`                    // The date and time, in ISO 8601 date-time format, when the policy was created.
	DefaultVersionId              string      `json:"defaultVersionId"`              // The identifier for the version of the policy that is set as the default version.
	Description                   string      `json:"description"`                   // A friendly description of the policy.
	IsAttachable                  bool        `json:"isAttachable"`                  // Specifies whether the policy can be attached to an IAM user, group, or role.
	Path                          string      `json:"path"`                          // The path to the policy.
	PermissionsBoundaryUsageCount int32       `json:"permissionsBoundaryUsageCount"` // The number of entities (users and roles) for which the policy is used to set the permissions boundary.
	PolicyId                      string      `json:"policyId"`                      // The stable and unique string identifying the policy.
	PolicyName                    string      `json:"policyName"`                    // The friendly name (not ARN) identifying the policy.
	Tags                          []types.Tag `json:"tags"`                          // A list of tags that are attached to the instance profile.
	UpdateDate                    time.Time   `json:"updateDate"`                    // The date and time, in ISO 8601 date-time format, when the policy was last updated.
}

Contains information about a managed policy.

func GetIamManagedPolicy

func GetIamManagedPolicy(t testing.TestingT, awsRegion string, policyArn string) *ManagedPolicy

Get IAM Managed Policy, fail on error

func GetIamManagedPolicyE

func GetIamManagedPolicyE(t testing.TestingT, awsRegion string, policyArn string) (*ManagedPolicy, error)

Get IAM Managed Policy, return result or error

type MultiValue

type MultiValue struct {
	Value string `json:"value"`
}

type MultiValueAttrs

type MultiValueAttrs struct {
	Value      string `json:"value"`
	Attributes string `json:"attributes"`
}

type QueueMessageResponse

type QueueMessageResponse struct {
	ReceiptHandle           string
	MessageBody             string
	ApproximateReceiveCount int64
	SentTimestamp           time.Time
	Error                   error
}

QueueMessageResponse contains a queue message.

func WaitForQueueMessage

func WaitForQueueMessage(t testing.TestingT, awsRegion string, queueURL string, timeout int) QueueMessageResponse

WaitForQueueMessage waits to receive a message from on the queueURL. Since the API only allows us to wait a max 20 seconds for a new message to arrive, we must loop TIMEOUT/20 number of times to be able to wait for a total of TIMEOUT seconds

type Request

type Request struct {
	Method      string      `json:"method"`
	URI         string      `json:"uri"`
	Querystring ValueObject `json:"querystring"`
	Headers     ValueObject `json:"headers"`
	Cookies     ValueObject `json:"cookies,omitempty"`
}

type Response

type Response struct {
	StatusCode        int             `json:"statusCode"`
	StatusDescription *string         `json:"statusDescription,omitempty"`
	Headers           *ValueObject    `json:"headers,omitempty"`
	Cookies           *ResponseCookie `json:"cookies,omitempty"`
}

type ResponseCookie

type ResponseCookie map[string]ResponseCookieEntry

type ResponseCookieEntry

type ResponseCookieEntry struct {
	Value      string            `json:"value"`
	Attributes string            `json:"attributes"`
	MultiValue []MultiValueAttrs `json:"multiValue,omitempty"`
}

type Role

type Role struct {
	Arn                      string                      `json:"arn"`                      // The Amazon Resource Name (ARN) specifying the role.
	AssumeRolePolicyDocument string                      `json:"assumeRolePolicyDocument"` // The policy that grants an entity permission to assume the role.
	CreateDate               time.Time                   `json:"createDate"`               // The date and time, in ISO 8601 date-time format, when the role was created.
	Description              string                      `json:"description"`              // A description of the role that you provide.
	MaxSessionDuration       int32                       `json:"maxSessionDuration"`       // The maximum session duration (in seconds) for the specified role.
	Path                     string                      `json:"path"`                     // The path to the role.
	PermissionsBoundary      AttachedPermissionsBoundary `json:"permissionsBoundary"`      // The ARN of the policy used to set the permissions boundary for the role.
	RoleId                   string                      `json:"roleId"`                   // The stable and unique string identifying the role.
	RoleLastUsed             types.RoleLastUsed          `json:"roleLastUsed"`             // Contains information about the last time that an IAM role was used.
	RoleName                 string                      `json:"roleName"`                 // The friendly name that identifies the role.
	InlinePolicies           []InlinePolicy              `json:"inlinePolicies"`           // The inline policies of the IAM role.
	AttachedPolicyArns       []string                    `json:"attachedPolicyArns"`       // The Amazon Resource Names (ARNs) of the managed policies attached to the role.
	Tags                     []types.Tag                 `json:"tags"`                     // A list of tags that are attached to the role.
}

IAM Role struct with Inline Policies and Attached Policy ARNs

func GetIamRole

func GetIamRole(t testing.TestingT, awsRegion string, roleName string) *Role

Get IAM Role with all inline policies and attached Policy ARNs, fail on error

func GetIamRoleE

func GetIamRoleE(t testing.TestingT, awsRegion string, roleName string) (*Role, error)

Get IAM Role with all inline policies and attached Policy ARNs, return result or error

type SfnExecutionOutput

type SfnExecutionOutput struct {
	// The current status of the execution.
	Status types.ExecutionStatus
	// The cause string if the state machine execution failed.
	Cause string
	// The error string if the state machine execution failed.
	Error string
	// The JSON output data of the execution. Length constraints apply to the payload
	// size, and are expressed as bytes in UTF-8 encoding.
	//
	// This field is set only if the execution succeeds. If the execution fails, this
	// field is the string Zero value ("").
	Output string
}

ExecutionOutput contains the result of the SateMachine Execution.

func WaitForSfnExecutionStatus

func WaitForSfnExecutionStatus(
	t testing.TestingT,
	awsRegion string,
	executionArn string,
	status types.ExecutionStatus,
	maxRetries int,
	sleepBetweenRetries time.Duration,
) *SfnExecutionOutput

WaitForSfnExecutionStatus waits for the specified execution to reach the desired status. This will fail the test if there is an error.

Executions of an EXPRESS state machine aren't supported by DescribeExecution unless a Map Run dispatched them.

func WaitForSfnExecutionStatusE

func WaitForSfnExecutionStatusE(
	t testing.TestingT,
	awsRegion string,
	executionArn string,
	status types.ExecutionStatus,
	maxRetries int,
	sleepBetweenRetries time.Duration,
) (*SfnExecutionOutput, error)

WaitForSfnExecutionStatusE waits for the specified execution to reach the desired status. this will throw error on timeout or non-retryable Errors.

type ValueEntry

type ValueEntry struct {
	Value      string       `json:"value"`
	MultiValue []MultiValue `json:"multiValue,omitempty"`
}

type ValueObject

type ValueObject map[string]ValueEntry

type Variables

type Variables map[string]any

func (*Variables) Apply

func (p *Variables) Apply(contents string) (string, error)

apply the variables to the test app

type Version

type Version string
const Version1_0 Version = "1.0"

func (Version) MarshalJSON

func (v Version) MarshalJSON() ([]byte, error)

func (*Version) UnmarshalJSON

func (v *Version) UnmarshalJSON(data []byte) error

type Viewer

type Viewer struct {
	IP string `json:"ip"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL