aws

package
v0.0.0-...-799102c Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const S3WebSiteEndPointEuCentral1 = ".s3-website.eu-central-1.amazonaws.com"

S3WebSiteEndPointEuCentral1 is the s3 endpoint for eu-central-1 s3-website.eu-central-1.amazonaws.com

Variables

This section is empty.

Functions

func MakeBucket

func MakeBucket(c context.Context, client S3BucketAPI, bucketname string) (string, error)

MakeBucket is used to create an s3 bucket with website config input: website name

func MakeRoutes

func MakeRoutes(c context.Context, client R53API, dnsname, zoneid string) (string, error)

MakeRoutes is used to create an R53 route for s3 bucket with website config input:

s3 website endpoint (https://docs.aws.amazon.com/general/latest/gr/s3.html#s3_website_region_endpoints)
dns name of the website
dns zone id

example endpoint http://www.testwebsite.devops.lk.s3-website.eu-central-1.amazonaws.com

func NewR53Client

func NewR53Client() (*r53.Client, error)

NewR53Client initializes a new aws R53 client.

func NewS3Client

func NewS3Client() (*s3.Client, error)

NewS3Client initializes a new aws s3 client.

func NewWebResources

func NewWebResources(c context.Context, webSiteName string, route53HostedZoneID string, skipBucketCreation bool) error

MakeWebResources is used to create an s3 bucket with website config and add required dns entries in Route53 input: website name, route 53 hosted zone id

func UploadContent

func UploadContent(c context.Context, webSiteName string) error

UploadContent is used to upload a file to a s3 bucket with website config. input: website name

func UploadContentFolder

func UploadContentFolder(c context.Context, uploadPath, webSiteName string) error

UploadContentFolder is used to upload multiple files to a s3 bucket with website config. input: website name

func UploadFile

func UploadFile(c context.Context, client S3BucketAPI, filename, bucketname string) error

func UploadFolder

func UploadFolder(c context.Context, client S3BucketAPI, localPath, bucketname string) error

UploadFolder implemnted using https://aws.github.io/aws-sdk-go-v2/docs/sdk-utilities/s3/

Types

type HostedZoneID

type HostedZoneID string

HostedZoneID represents aws s3 hostedzoneids

const (
	//USEast1HostedZoneID is the s3 web endpoint hosted zone id
	USEast1HostedZoneID HostedZoneID = "Z3AQBSTGFYJSTF"
	//USEast2HostedZoneID is the s3 web endpoint hosted zone id
	USEast2HostedZoneID HostedZoneID = "Z2O1EMRO9K5GLX"
	//USWest1HostedZoneID  is the s3 web endpoint hosted zone id
	USWest1HostedZoneID HostedZoneID = "Z2F56UZL2M1ACD"
	//USWest2HostedZoneID  is the s3 web endpoint hosted zone id
	USWest2HostedZoneID HostedZoneID = "Z3BJ6K6RIION7M"
	//EUCentralHostedZoneID is the s3 web endpoint hosted zone id
	EUCentralHostedZoneID HostedZoneID = "Z21DNDUVLTQW6Q"
	//EUWestHostedZoneID  is the s3 web endpoint hosted zone id
	EUWestHostedZoneID HostedZoneID = "Z1BKCTXD74EZPE"
)

type R53API

type R53API interface {
	ChangeResourceRecordSets(ctx context.Context,
		params *r53.ChangeResourceRecordSetsInput,
		optFns ...func(*r53.Options)) (*r53.ChangeResourceRecordSetsOutput, error)
}

R53API defines the interface for the CreateHostedZone function. We use this interface to test the function using a mocked service.

type S3BucketAPI

type S3BucketAPI interface {
	CreateBucket(ctx context.Context,
		params *s3.CreateBucketInput,
		optFns ...func(*s3.Options)) (*s3.CreateBucketOutput, error)
	PutBucketWebsite(ctx context.Context,
		params *s3.PutBucketWebsiteInput,
		optFns ...func(*s3.Options)) (*s3.PutBucketWebsiteOutput, error)
	PutObject(ctx context.Context,
		params *s3.PutObjectInput,
		optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)
}

S3BucketAPI defines the interface for the S3 functionaliteis with Create Bucket, PutBucketWebiste, PutObject functions. We use this interface to test the function using a mocked service.

Jump to

Keyboard shortcuts

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