Skip to content

Commit

Permalink
provided.al2 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
msummers-nr committed Nov 13, 2023
1 parent fc208d1 commit 234a20d
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 24 deletions.
3 changes: 0 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ repos:
description: Run pytest in the local virtualenv
entry: >
pytest
--cov-report=term
--cov-report=html
--cov="rpdk.go"
--durations=5
"tests/"
language: system
Expand Down
1 change: 0 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ persistent=yes
disable=
missing-docstring, # not everything needs a docstring
fixme, # work in progress
bad-continuation, # clashes with black
too-few-public-methods, # triggers when inheriting
ungrouped-imports, # clashes with isort
duplicate-code, # broken, setup.py
Expand Down
6 changes: 3 additions & 3 deletions examples/github-repo/.rpdk-config
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"typeName": "Example::GitHub::Repo",
"language": "go",
"runtime": "go1.x",
"entrypoint": "handler",
"testEntrypoint": "handler",
"runtime": "provided.al2",
"entrypoint": "bootstrap",
"testEntrypoint": "bootstrap",
"settings": {
"import_path": "github.com/aws-cloudformation/cloudformation-cli-go-plugin/examples/github-repo",
"protocolVersion": "2.0.0",
Expand Down
19 changes: 19 additions & 0 deletions examples/github-repo/cmd/resource/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions examples/github-repo/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ _Required_: Yes

_Type_: String

_Minimum_: <code>1</code>
_Minimum Length_: <code>1</code>

_Maximum_: <code>50</code>
_Maximum Length_: <code>50</code>

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

Expand All @@ -67,9 +67,9 @@ _Required_: No

_Type_: String

_Minimum_: <code>20</code>
_Minimum Length_: <code>20</code>

_Maximum_: <code>250</code>
_Maximum Length_: <code>250</code>

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

Expand All @@ -81,9 +81,9 @@ _Required_: No

_Type_: String

_Minimum_: <code>20</code>
_Minimum Length_: <code>20</code>

_Maximum_: <code>250</code>
_Maximum Length_: <code>250</code>

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

Expand Down
8 changes: 8 additions & 0 deletions examples/github-repo/makebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file is autogenerated, do not edit;
# changes will be undone by the next 'generate' command.

.PHONY: build
build:
cfn generate
#env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -tags="$(TAGS)" -o bin/handler cmd/main.go
env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -tags="lambda.norpc,$(TAGS)" -o bin/bootstrap cmd/main.go #local
7 changes: 7 additions & 0 deletions examples/github-repo/resource-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ Resources:
Principal:
Service: resources.cloudformation.amazonaws.com
Action: sts:AssumeRole
Condition:
StringEquals:
aws:SourceAccount:
Ref: AWS::AccountId
StringLike:
aws:SourceArn:
Fn::Sub: arn:${AWS::Partition}:cloudformation:${AWS::Region}:${AWS::AccountId}:type/resource/Example-GitHub-Repo/*
Path: "/"
Policies:
- PolicyName: ResourceTypePolicy
Expand Down
16 changes: 12 additions & 4 deletions examples/github-repo/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ Globals:
Resources:
TypeFunction:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: go1.x
Properties:
Handler: handler
Runtime: go1.x
Handler: bootstrap
Runtime: provided.al2
Architectures:
- x86_64
CodeUri: bin/
# Uncomment to test with AWS resources
# Environment:
Expand All @@ -20,7 +24,11 @@ Resources:

TestEntrypoint:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: go1.x
Properties:
Handler: handler
Runtime: go1.x
Handler: bootstrap
Runtime: provided.al2
Architectures:
- x86_64
CodeUri: bin/
10 changes: 5 additions & 5 deletions python/rpdk/go/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class GoExecutableNotFoundError(SysExitRecommendedError):
class GoLanguagePlugin(LanguagePlugin):
MODULE_NAME = __name__
NAME = "go"
RUNTIME = "go1.x"
ENTRY_POINT = "handler"
TEST_ENTRY_POINT = "handler"
RUNTIME = "provided.al2"
ENTRY_POINT = "bootstrap"
TEST_ENTRY_POINT = "bootstrap"
CODE_URI = "bin/"

def __init__(self):
Expand Down Expand Up @@ -154,7 +154,7 @@ def init_handlers(self, project: Project, src):
contents = template.render()
project.safewrite(path, contents)

# pylint: disable=unused-argument,no-self-use
# pylint: disable=unused-argument
def _get_generated_root(self, project: Project):
LOG.debug("Init started")

Expand Down Expand Up @@ -251,7 +251,7 @@ def pre_package(project: Project):

@staticmethod
def _find_exe(project: Project):
exe_glob = list((project.root / "bin").glob("handler"))
exe_glob = list((project.root / "bin").glob("bootstrap"))
if not exe_glob:
LOG.debug("No Go executable match")
raise GoExecutableNotFoundError(
Expand Down
2 changes: 1 addition & 1 deletion python/rpdk/go/templates/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build:

test:
cfn generate
env GOOS=linux go build -ldflags="-s -w" -o bin/handler cmd/main.go
env GOOS=linux go build -ldflags="-s -w" -tags="lambda.norpc,$(TAGS)" -o bin/bootstrap cmd/main.go

clean:
rm -rf bin
2 changes: 1 addition & 1 deletion python/rpdk/go/templates/makebuild
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
.PHONY: build
build:
cfn generate
env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -tags="$(TAGS)" -o bin/handler cmd/main.go
env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -tags="lambda.norpc,$(TAGS)" -o bin/bootstrap cmd/main.go

0 comments on commit 234a20d

Please sign in to comment.