resources

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 6 Imported by: 2

Documentation

Overview

Example (Api)
c := &Config{
	Config: &up.Config{
		Name: "polls",
	},
}

dump(c, "Api")
Output:

{
  "Properties": {
    "BinaryMediaTypes": [
      "*/*"
    ],
    "Description": "Managed by Up.",
    "Name": {
      "Ref": "Name"
    }
  },
  "Type": "AWS::ApiGateway::RestApi"
}
Example (ApiProxyMethod)
c := &Config{
	Config: &up.Config{
		Name: "polls",
	},
}

dump(c, "ApiProxyMethod")
Output:

{
  "Properties": {
    "AuthorizationType": "NONE",
    "HttpMethod": "ANY",
    "Integration": {
      "IntegrationHttpMethod": "POST",
      "Type": "AWS_PROXY",
      "Uri": {
        "Fn::Join": [
          "",
          [
            "arn:aws:apigateway:",
            {
              "Ref": "AWS::Region"
            },
            ":lambda:path/2015-03-31/functions/",
            {
              "Fn::Join": [
                ":",
                [
                  "arn",
                  "aws",
                  "lambda",
                  {
                    "Ref": "AWS::Region"
                  },
                  {
                    "Ref": "AWS::AccountId"
                  },
                  "function",
                  {
                    "Fn::Join": [
                      ":",
                      [
                        {
                          "Ref": "FunctionName"
                        },
                        "${stageVariables.qualifier}"
                      ]
                    ]
                  }
                ]
              ]
            },
            "/invocations"
          ]
        ]
      }
    },
    "ResourceId": {
      "Ref": "ApiProxyResource"
    },
    "RestApiId": {
      "Ref": "Api"
    }
  },
  "Type": "AWS::ApiGateway::Method"
}
Example (ApiProxyResource)
c := &Config{
	Config: &up.Config{
		Name: "polls",
	},
}

dump(c, "ApiProxyResource")
Output:

{
  "Properties": {
    "ParentId": {
      "Fn::GetAtt": [
        "Api",
        "RootResourceId"
      ]
    },
    "PathPart": "{proxy+}",
    "RestApiId": {
      "Ref": "Api"
    }
  },
  "Type": "AWS::ApiGateway::Resource"
}
Example (ApiRootMethod)
c := &Config{
	Config: &up.Config{
		Name: "polls",
	},
}

dump(c, "ApiRootMethod")
Output:

{
  "Properties": {
    "AuthorizationType": "NONE",
    "HttpMethod": "ANY",
    "Integration": {
      "IntegrationHttpMethod": "POST",
      "Type": "AWS_PROXY",
      "Uri": {
        "Fn::Join": [
          "",
          [
            "arn:aws:apigateway:",
            {
              "Ref": "AWS::Region"
            },
            ":lambda:path/2015-03-31/functions/",
            {
              "Fn::Join": [
                ":",
                [
                  "arn",
                  "aws",
                  "lambda",
                  {
                    "Ref": "AWS::Region"
                  },
                  {
                    "Ref": "AWS::AccountId"
                  },
                  "function",
                  {
                    "Fn::Join": [
                      ":",
                      [
                        {
                          "Ref": "FunctionName"
                        },
                        "${stageVariables.qualifier}"
                      ]
                    ]
                  }
                ]
              ]
            },
            "/invocations"
          ]
        ]
      }
    },
    "ResourceId": {
      "Fn::GetAtt": [
        "Api",
        "RootResourceId"
      ]
    },
    "RestApiId": {
      "Ref": "Api"
    }
  },
  "Type": "AWS::ApiGateway::Method"
}
Example (DnsZone)
c := &Config{
	Config: &up.Config{
		Name: "polls",
		DNS: config.DNS{
			Zones: []*config.Zone{
				{
					Name: "up-example.com",
				},
			},
		},
	},
}

dump(c, "DnsZoneUpExampleCom")
Output:

{
  "DeletionPolicy": "Retain",
  "Properties": {
    "Name": "up-example.com"
  },
  "Type": "AWS::Route53::HostedZone",
  "UpdateReplacePolicy": "Retain"
}
Example (DnsZoneRecord)
c := &Config{
	Config: &up.Config{
		Name: "polls",
		DNS: config.DNS{
			Zones: []*config.Zone{
				{
					Name: "up-example.com",
					Records: []*config.Record{
						{
							Name:  "blog.up-example.com",
							Type:  "CNAME",
							TTL:   600,
							Value: []string{"example.medium.com"},
						},
					},
				},
			},
		},
	},
}

dump(c, "DnsZoneUpExampleComRecordBlogUpExampleComCNAME")
Output:

{
  "Properties": {
    "Comment": "Managed by Up.",
    "HostedZoneId": {
      "Ref": "DnsZoneUpExampleCom"
    },
    "Name": "blog.up-example.com",
    "ResourceRecords": [
      "example.medium.com"
    ],
    "TTL": "600",
    "Type": "CNAME"
  },
  "Type": "AWS::Route53::RecordSet"
}
Example (StageAlias)
c := &Config{
	Config: &up.Config{
		Name: "polls",
		Stages: config.Stages{
			"production": &config.Stage{
				Name: "production",
			},
		},
	},
	Versions: Versions{
		"production": "15",
	},
}

dump(c, "ApiFunctionAliasProduction")
Output:

{
  "Properties": {
    "Description": "Managed by Up.",
    "FunctionName": {
      "Ref": "FunctionName"
    },
    "FunctionVersion": "15",
    "Name": "production"
  },
  "Type": "AWS::Lambda::Alias"
}
Example (StageDNSZone)
c := &Config{
	Config: &up.Config{
		Name: "polls",
		Stages: config.Stages{
			"production": &config.Stage{
				Name:   "production",
				Domain: "up-example.com",
			},
		},
	},
	Versions: Versions{
		"production": "15",
	},
}

dump(c, "DnsZoneUpExampleCom")
Output:

{
  "DeletionPolicy": "Retain",
  "Properties": {
    "Name": "up-example.com"
  },
  "Type": "AWS::Route53::HostedZone",
  "UpdateReplacePolicy": "Retain"
}
Example (StageDNSZoneRecord)
c := &Config{
	Config: &up.Config{
		Name: "polls",
		Stages: config.Stages{
			"production": &config.Stage{
				Name:   "production",
				Domain: "up-example.com",
			},
		},
	},
	Versions: Versions{
		"production": "15",
	},
}

dump(c, "DnsZoneUpExampleComRecordUpExampleCom")
Output:

{
  "Properties": {
    "AliasTarget": {
      "DNSName": {
        "Fn::GetAtt": [
          "ApiDomainProduction",
          "DistributionDomainName"
        ]
      },
      "HostedZoneId": "Z2FDTNDATAQYW2"
    },
    "Comment": "Managed by Up.",
    "HostedZoneId": {
      "Ref": "DnsZoneUpExampleCom"
    },
    "Name": "up-example.com",
    "Type": "A"
  },
  "Type": "AWS::Route53::RecordSet"
}
Example (StageDeployment)
c := &Config{
	Config: &up.Config{
		Name: "polls",
		Stages: config.Stages{
			"production": &config.Stage{
				Name: "production",
			},
		},
	},
	Versions: Versions{
		"production": "15",
	},
}

dump(c, "ApiDeploymentProduction")
Output:

{
  "DependsOn": [
    "ApiRootMethod",
    "ApiProxyMethod",
    "ApiFunctionAliasProduction"
  ],
  "Properties": {
    "RestApiId": {
      "Ref": "Api"
    },
    "StageDescription": {
      "Variables": {
        "qualifier": "production"
      }
    },
    "StageName": "production"
  },
  "Type": "AWS::ApiGateway::Deployment"
}
Example (StageDomain)
c := &Config{
	Config: &up.Config{
		Name: "polls",
		Stages: config.Stages{
			"production": &config.Stage{
				Name:   "production",
				Domain: "up-example.com",
				Cert:   "arn::something",
			},
		},
	},
	Versions: Versions{
		"production": "15",
	},
}

dump(c, "ApiDomainProduction")
Output:

	{
  "Properties": {
    "CertificateArn": "arn::something",
    "DomainName": "up-example.com"
  },
  "Type": "AWS::ApiGateway::DomainName"
}
Example (StagePathMapping)
c := &Config{
	Config: &up.Config{
		Name: "polls",
		Stages: config.Stages{
			"production": &config.Stage{
				Name:   "production",
				Domain: "up-example.com",
			},
		},
	},
	Versions: Versions{
		"production": "15",
	},
}

dump(c, "ApiDomainProductionPathMapping")
Output:

{
  "DependsOn": [
    "ApiDeploymentProduction",
    "ApiDomainProduction"
  ],
  "Properties": {
    "BasePath": "",
    "DomainName": "up-example.com",
    "RestApiId": {
      "Ref": "Api"
    },
    "Stage": "production"
  },
  "Type": "AWS::ApiGateway::BasePathMapping"
}
Example (StagePermission)
c := &Config{
	Config: &up.Config{
		Name: "polls",
		Stages: config.Stages{
			"production": &config.Stage{
				Name: "production",
			},
		},
	},
	Versions: Versions{
		"production": "15",
	},
}

dump(c, "ApiLambdaPermissionProduction")
Output:

{
  "DependsOn": "ApiFunctionAliasProduction",
  "Properties": {
    "Action": "lambda:invokeFunction",
    "FunctionName": {
      "Fn::Join": [
        ":",
        [
          "arn",
          "aws",
          "lambda",
          {
            "Ref": "AWS::Region"
          },
          {
            "Ref": "AWS::AccountId"
          },
          "function",
          {
            "Fn::Join": [
              ":",
              [
                {
                  "Ref": "FunctionName"
                },
                "production"
              ]
            ]
          }
        ]
      ]
    },
    "Principal": "apigateway.amazonaws.com",
    "SourceArn": {
      "Fn::Join": [
        "",
        [
          "arn:aws:execute-api",
          ":",
          {
            "Ref": "AWS::Region"
          },
          ":",
          {
            "Ref": "AWS::AccountId"
          },
          ":",
          {
            "Ref": "Api"
          },
          "/*"
        ]
      ]
    }
  },
  "Type": "AWS::Lambda::Permission"
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(c *Config) map[string]interface{}

New template.

Types

type Config

type Config struct {
	// Zones already present in route53. This is used to
	// ensure that existing zones previously set up, or
	// automatically configured when purchasing a domain
	// are not duplicated.
	Zones []*route53.HostedZone

	// Versions map used to maintain the correct lambda
	// function aliases when updating a stack.
	Versions Versions

	*up.Config
}

Config for the resource template.

type Map

type Map map[string]interface{}

Map type.

type Versions

type Versions map[string]string

Versions is a map of stage to lambda function version.

Jump to

Keyboard shortcuts

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