Documentation ¶
Index ¶
- Constants
- Variables
- type Behavior
- type CallerRefFn
- type DistRepository
- type Distribution
- type DistributionBuilder
- func (b DistributionBuilder) AppendTags(tags map[string]string) DistributionBuilder
- func (b DistributionBuilder) Build() (Distribution, error)
- func (b DistributionBuilder) WithARN(arn string) DistributionBuilder
- func (b DistributionBuilder) WithAlternateDomains(domains []string) DistributionBuilder
- func (b DistributionBuilder) WithIPv6() DistributionBuilder
- func (b DistributionBuilder) WithLogging(bucketAddress, prefix string) DistributionBuilder
- func (b DistributionBuilder) WithOrigin(o Origin) DistributionBuilder
- func (b DistributionBuilder) WithTLS(certARN, securityPolicyID string) DistributionBuilder
- func (b DistributionBuilder) WithWebACL(id string) DistributionBuilder
- type DistributionRepository
- type OAC
- type OACLister
- type OACRepository
- type Origin
- type OriginBuilder
- func (b OriginBuilder) Build() Origin
- func (b OriginBuilder) WithBehavior(pathPattern string) OriginBuilder
- func (b OriginBuilder) WithCachePolicy(policy string) OriginBuilder
- func (b OriginBuilder) WithRequestPolicy(policy string) OriginBuilder
- func (b OriginBuilder) WithResponseTimeout(rpTimeout int64) OriginBuilder
- func (b OriginBuilder) WithViewerFunction(fnARN string) OriginBuilder
- type PostCreationOperationsFunc
- type Service
Constants ¶
const ( OriginAccessPublic = k8s.CFUserOriginAccessPublic OriginAccessBucket = k8s.CFUserOriginAccessBucket )
Variables ¶
var ErrDistNotFound = errors.New("distribution not found")
ErrDistNotFound represents failure when finding/fetching a distribution
Functions ¶
This section is empty.
Types ¶
type Behavior ¶
type Behavior struct { // PathPattern is the path pattern used when configuring the Behavior PathPattern string // RequestPolicy is the ID of the origin request policy to be associated with this Behavior RequestPolicy string // CachePolicy is the ID of the cache policy to be associated with this Behavior CachePolicy string // ViewerFnARN is the ARN of the function to be associated with the Behavior's viewer requests ViewerFnARN string // OriginHost the origin's host this behavior belongs to OriginHost string }
Behavior represents a CloudFront Cache Behavior
type CallerRefFn ¶ added in v0.0.8
type CallerRefFn func() string
CallerRefFn is the function that should be called when setting the request's caller reference. It should be a unique identifier to prevent the request from being replayed. https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CreateDistribution.html
type DistRepository ¶ added in v0.1.1
type DistRepository struct { CloudFrontClient cloudfrontiface.CloudFrontAPI OACRepo OACRepository TaggingClient resourcegroupstaggingapiiface.ResourceGroupsTaggingAPIAPI CallerRef CallerRefFn WaitTimeout time.Duration RunPostCreationOperations PostCreationOperationsFunc Cfg config.Config }
func (DistRepository) ARNByGroup ¶ added in v0.1.1
func (r DistRepository) ARNByGroup(group string) (string, error)
func (DistRepository) Create ¶ added in v0.1.1
func (r DistRepository) Create(d Distribution) (Distribution, error)
func (DistRepository) Delete ¶ added in v0.1.1
func (r DistRepository) Delete(d Distribution) error
func (DistRepository) Sync ¶ added in v0.1.1
func (r DistRepository) Sync(d Distribution) (Distribution, error)
type Distribution ¶ added in v0.0.7
type Distribution struct { ID string ARN string Address string AlternateDomains []string CustomOrigins []Origin DefaultOrigin Origin Description string Group string IPv6Enabled bool Logging loggingConfig PriceClass string Tags map[string]string TLS tlsConfig WebACLID string }
Distribution represents a CloudFront distribution
func (Distribution) Exists ¶ added in v0.0.13
func (d Distribution) Exists() bool
Exists returns whether this Distribution exists on AWS or not
func (Distribution) HasOrigin ¶ added in v0.1.1
func (d Distribution) HasOrigin(originHost string) bool
func (Distribution) IsEmpty ¶ added in v0.0.13
func (d Distribution) IsEmpty() bool
IsEmpty return whether this Distribution has custom origins/behaviors
func (Distribution) OACs ¶ added in v0.1.1
func (d Distribution) OACs() []OAC
func (Distribution) SortedCustomBehaviors ¶ added in v0.0.13
func (d Distribution) SortedCustomBehaviors() []Behavior
SortedCustomBehaviors returns a slice of all custom Behavior sorted by descending path length
type DistributionBuilder ¶ added in v0.0.7
type DistributionBuilder struct {
// contains filtered or unexported fields
}
DistributionBuilder allows the construction of a Distribution
func NewDistributionBuilder ¶ added in v0.0.7
func NewDistributionBuilder(group string, cfg config.Config) DistributionBuilder
NewDistributionBuilder takes required arguments for a distribution and returns a DistributionBuilder
func (DistributionBuilder) AppendTags ¶ added in v0.0.15
func (b DistributionBuilder) AppendTags(tags map[string]string) DistributionBuilder
AppendTags takes in custom tags which should be present at the Distribution
func (DistributionBuilder) Build ¶ added in v0.0.7
func (b DistributionBuilder) Build() (Distribution, error)
Build constructs a Distribution taking into account all configuration set by previous "With*" method calls
func (DistributionBuilder) WithARN ¶ added in v0.0.13
func (b DistributionBuilder) WithARN(arn string) DistributionBuilder
WithARN takes in identifying information from an existing CloudFront to populate the resulting Distribution
func (DistributionBuilder) WithAlternateDomains ¶ added in v0.0.7
func (b DistributionBuilder) WithAlternateDomains(domains []string) DistributionBuilder
WithAlternateDomains takes a slice of domains to be added to the Distribution's alternate domains
func (DistributionBuilder) WithIPv6 ¶ added in v0.0.7
func (b DistributionBuilder) WithIPv6() DistributionBuilder
WithIPv6 enables IPv6
func (DistributionBuilder) WithLogging ¶ added in v0.0.7
func (b DistributionBuilder) WithLogging(bucketAddress, prefix string) DistributionBuilder
WithLogging takes in bucket address and file prefix to enable sending CF logs to S3
func (DistributionBuilder) WithOrigin ¶ added in v0.0.8
func (b DistributionBuilder) WithOrigin(o Origin) DistributionBuilder
WithOrigin takes in an Origin that should be part of the Distribution
func (DistributionBuilder) WithTLS ¶ added in v0.0.7
func (b DistributionBuilder) WithTLS(certARN, securityPolicyID string) DistributionBuilder
WithTLS takes in an ACM certificate ARN and a Security Policy ID to enable TLS termination
func (DistributionBuilder) WithWebACL ¶ added in v0.0.7
func (b DistributionBuilder) WithWebACL(id string) DistributionBuilder
WithWebACL takes the ID of the Web ACL that should be associated with the Distribution
type DistributionRepository ¶ added in v0.0.8
type DistributionRepository interface { // ARNByGroup fetches the ARN from an existing Distribution in AWS that is owned by the operator and was created for // the given group. // Returns ErrDistNotFound if no existing Distribution was found. ARNByGroup(group string) (string, error) // Create creates the given Distribution on CloudFront. Returns the created dist. Create(Distribution) (Distribution, error) // Sync ensures the given Distribution is correctly configured on CloudFront. Returns synced dist. Sync(Distribution) (Distribution, error) // Delete deletes the Distribution at AWS Delete(Distribution) error }
DistributionRepository provides a DistRepository for manipulating CloudFront distributions to match desired configuration
type OAC ¶ added in v0.1.1
type OAC struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` OriginName string `json:"originName"` OriginAccessControlOriginType string `json:"originAccessControlOriginType"` SigningBehavior string `json:"signingBehavior"` SigningProtocol string `json:"signingProtocol"` }
type OACLister ¶ added in v0.1.1
type OACLister interface { ListOriginAccessControlsPages(input *awscloudfront.ListOriginAccessControlsInput, fn func(*awscloudfront.ListOriginAccessControlsOutput, bool) bool) error ListOriginAccessControlsPagesWithContext(ctx context.Context, input *awscloudfront.ListOriginAccessControlsInput, fn func(*awscloudfront.ListOriginAccessControlsOutput, bool) bool, opts ...request.Option) error }
OACLister lists OACs. Using an interface to make it more testable, since otherwise we'd need to create fake requests, which can't be mocked because they are not interfaces.
func NewOACLister ¶ added in v0.1.1
func NewOACLister(client cloudfrontiface.CloudFrontAPI) OACLister
type OACRepository ¶ added in v0.1.1
type OACRepository interface { // Sync updates or creates a desired OAC. If successful, returns current OAC Sync(desired OAC) (OAC, error) // Delete deletes the OAC of given id. If successful, returns deleted OAC Delete(toBeDeleted OAC) (OAC, error) }
func NewOACRepository ¶ added in v0.1.1
func NewOACRepository(client cloudfrontiface.CloudFrontAPI, oacLister OACLister, cfg config.Config) OACRepository
type Origin ¶
type Origin struct { // Host is the origin's hostname Host string // Behaviors is the collection of Behaviors associated with this Origin Behaviors []Behavior // ResponseTimeout is how long CloudFront will wait for a response from the Origin in seconds ResponseTimeout int64 // Access is this Origin's access type (Bucket or Public) Access string // OAC configures Access Origin Control for this Origin OAC OAC }
Origin represents a CloudFront Origin and aggregates Behaviors associated with it
func (Origin) HasEqualParameters ¶ added in v0.0.8
HasEqualParameters returns whether both Origins have the same parameters. It ignores differences in Behaviors
type OriginBuilder ¶
type OriginBuilder struct {
// contains filtered or unexported fields
}
OriginBuilder allows the construction of a Origin
func NewOriginBuilder ¶
func NewOriginBuilder(distributionName, host, accessType string, cfg config.Config) OriginBuilder
NewOriginBuilder returns an OriginBuilder for a given host
func (OriginBuilder) Build ¶
func (b OriginBuilder) Build() Origin
Build creates an Origin based on configuration made so far
func (OriginBuilder) WithBehavior ¶
func (b OriginBuilder) WithBehavior(pathPattern string) OriginBuilder
WithBehavior adds a Behavior to the Origin being built given a path pattern the Behavior should respond for
func (OriginBuilder) WithCachePolicy ¶ added in v0.0.10
func (b OriginBuilder) WithCachePolicy(policy string) OriginBuilder
WithCachePolicy associates a given cache policy ID with all Behaviors in the Origin being built
func (OriginBuilder) WithRequestPolicy ¶ added in v0.0.8
func (b OriginBuilder) WithRequestPolicy(policy string) OriginBuilder
WithRequestPolicy associates a given origin request policy ID with all Behaviors in the Origin being built
func (OriginBuilder) WithResponseTimeout ¶ added in v0.0.6
func (b OriginBuilder) WithResponseTimeout(rpTimeout int64) OriginBuilder
WithResponseTimeout associates a custom response timeout to custom origin
func (OriginBuilder) WithViewerFunction ¶ added in v0.0.5
func (b OriginBuilder) WithViewerFunction(fnARN string) OriginBuilder
WithViewerFunction associates a function with all viewer requests of all Behaviors in the Origin being built
type PostCreationOperationsFunc ¶ added in v0.1.1
type PostCreationOperationsFunc func(Distribution) (Distribution, error)
PostCreationOperationsFunc executes necessary operations on a recently-created Distribution. Useful for stuff that requires the Distribution to already exist in the first place, like attaching OACs to origins.
type Service ¶ added in v0.0.13
type Service struct { client.Client Config config.Config Recorder record.EventRecorder AliasRepo route53.AliasRepository DistRepo DistributionRepository Fetcher k8s.IngressFetcher }
Service handles operations involving CloudFront