diff --git a/GitHub-Repositories-Repository/docs/README.md b/GitHub-Repositories-Repository/docs/README.md index e7153bb..dcf4add 100644 --- a/GitHub-Repositories-Repository/docs/README.md +++ b/GitHub-Repositories-Repository/docs/README.md @@ -87,7 +87,7 @@ _Required_: Yes _Type_: String -_Update requires_: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement) +_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt) #### Description @@ -301,6 +301,10 @@ The `Fn::GetAtt` intrinsic function returns a value for a specified attribute of For more information about using the `Fn::GetAtt` intrinsic function, see [Fn::GetAtt](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html). +#### Id + +The ID of the repository. + #### Owner ID of the repository owner. diff --git a/GitHub-Repositories-Repository/github-repositories-repository.json b/GitHub-Repositories-Repository/github-repositories-repository.json index f563715..f1c7950 100644 --- a/GitHub-Repositories-Repository/github-repositories-repository.json +++ b/GitHub-Repositories-Repository/github-repositories-repository.json @@ -100,6 +100,10 @@ ] }, "properties": { + "Id": { + "description": "The ID of the repository.", + "type": "number" + }, "Organization": { "description": "The organization name. The name is not case sensitive. If not specified, then the managed repository will be within the currently logged-in user account.", "type": "string" @@ -245,6 +249,7 @@ "Name" ], "readOnlyProperties": [ + "/properties/Id", "/properties/Owner", "/properties/HtmlUrl", "/properties/GitUrl", @@ -257,7 +262,6 @@ ], "createOnlyProperties": [ "/properties/Organization", - "/properties/Name", "/properties/TeamId", "/properties/AutoInit", "/properties/GitIgnoreTemplate", @@ -273,24 +277,34 @@ "/properties/SecurityAndAnalysis" ], "primaryIdentifier": [ - "/properties/Owner", - "/properties/Name" + "/properties/Id", + "/properties/Owner" ], "handlers": { "create": { - "permissions": [] + "permissions": [ + "appsync:CreateApiKey" + ] }, "read": { - "permissions": [] + "permissions": [ + "appsync:CreateApiKey" + ] }, "update": { - "permissions": [] + "permissions": [ + "appsync:CreateApiKey" + ] }, "delete": { - "permissions": [] + "permissions": [ + "appsync:CreateApiKey" + ] }, "list": { - "permissions": [] + "permissions": [ + "appsync:CreateApiKey" + ] } } } diff --git a/GitHub-Repositories-Repository/package-lock.json b/GitHub-Repositories-Repository/package-lock.json index d157329..518ba4a 100644 --- a/GitHub-Repositories-Repository/package-lock.json +++ b/GitHub-Repositories-Repository/package-lock.json @@ -11,7 +11,6 @@ "@amazon-web-services-cloudformation/cloudformation-cli-typescript-lib": "^1.0.3", "@octokit/core": "^4.1.0", "@octokit/rest": "^19.0.5", - "aws-sdk": "^2.1354.0", "class-transformer": "0.3.1" }, "devDependencies": { diff --git a/GitHub-Repositories-Repository/resource-role.yaml b/GitHub-Repositories-Repository/resource-role.yaml index 18b33ff..b82cbfb 100644 --- a/GitHub-Repositories-Repository/resource-role.yaml +++ b/GitHub-Repositories-Repository/resource-role.yaml @@ -28,9 +28,9 @@ Resources: PolicyDocument: Version: '2012-10-17' Statement: - - Effect: Deny + - Effect: Allow Action: - - "*" + - "appsync:CreateApiKey" Resource: "*" Outputs: ExecutionRoleArn: diff --git a/GitHub-Repositories-Repository/src/handlers.ts b/GitHub-Repositories-Repository/src/handlers.ts index c6bed98..0f60ca6 100644 --- a/GitHub-Repositories-Repository/src/handlers.ts +++ b/GitHub-Repositories-Repository/src/handlers.ts @@ -67,9 +67,13 @@ class Resource extends AbstractGitHubResource('GET /repos/{owner}/{repo}', { - owner: model.owner, - repo: model.name + // Note - in order to allow renaming the github repo, we need to use the id instead of owner and name for the path. + // See here for more information about this api (since it's undocumented): https://github.com/piotrmurach/github/issues/282 + // ts ignore below necessary as this path is not part of octokit endpoints + + // @ts-ignore + const response = await octokit.request('GET /repositories/{id}', { + id: model.id }); return response.data; @@ -168,9 +172,14 @@ class Resource extends AbstractGitHubResource( - 'PATCH /repos/{owner}/{repo}', - payload); + const pathWithId = `PATCH /repositories/${model.id}`; + + // Note - in order to allow renaming the github repo, we need to use the id instead of owner and name for the path. + // See here for more information about this api (since it's undocumented): https://github.com/piotrmurach/github/issues/282 + // ts ignore below necessary as this path is not part of octokit endpoints + + // @ts-ignore + const response = await octokit.request(pathWithId, payload); return response.data; } @@ -181,9 +190,8 @@ class Resource extends AbstractGitHubResource + transformValue(Number, 'id', value, obj, []), + { + toClassOnly: true, + } + ) + id?: Optional; @Expose({ name: 'Organization' }) @Transform( (value: any, obj: any) => @@ -290,12 +299,12 @@ export class ResourceModel extends BaseModel { @Exclude() public getPrimaryIdentifier(): Dict { const identifier: Dict = {}; - if (this.owner != null) { - identifier[this.IDENTIFIER_KEY_OWNER] = this.owner; + if (this.id != null) { + identifier[this.IDENTIFIER_KEY_ID] = this.id; } - if (this.name != null) { - identifier[this.IDENTIFIER_KEY_NAME] = this.name; + if (this.owner != null) { + identifier[this.IDENTIFIER_KEY_OWNER] = this.owner; } // only return the identifier if it can be used, i.e. if all components are present