AWS Cloudformation tying Amplify to bitbucket Repo - amazon-web-services

I am using CloudFormation to deploy a multilayer application that includes APIGateways, Lambdas, and all the resources created in Amplify and EB. We built each part of the stack manual. Now we are trying to tie them together in one CloudFormation Template. Where we are tripped up is tying the AWS::Amplify::App to our repository in Bitbucket. The account token setting seems not to be available in our bitbucket instance. Is there another way to tie the amplifying part of the CFN template to that repo? or S3?

Related

Migrate SQS and SNS configuration

We have a few different AWS accounts and I am looking to migrate the SNS configuration from one AWS account to another. Is that possible to migrate?
Many thanks for considering my request.
AWS does not have a 'migrate' capability.
A best-practice is to deploy "infrastructure as code" using CloudFormation or Terraform. Then, when you wish to deploy the same infrastructure to a different AWS Account, simply use the same template to deploy it.
If you did not deploy your initial infrastructure via a template, you might want to use https://former2.com/ to create a template based on existing infrastructure. You can then use that template to deploy the same resources in a different AWS Account.

CloudFormation - obtaining template from a repo

Can someone list for me the steps needed in order to obtain a template from Azure DevOps repo and have AWS Cloud Formation use it to build a stack.
Interested in best practices and some high-level steps please / requirements E.G. do I need AWS Pipelines? AWS Azure Toolkit?
One of the cleaner ways that I could think of doing this is integrating your DevOps repository with an S3 bucket and then triggering AWS CodePipeline to deploy the stack from the S3 bucket.
The flow would be something like,
Create a bucket in S3 to hold the cf template
Create a service connection request in DevOps repo, this should push the template to S3 every time changes are deployed
Create an AWS CodePipeline workflow that takes the template as input from S3 and deploys it to CloudFormation

Amplify Cloudformation templates

My understanding of Amplify is that on amplify push, it somehow processes the separate cloudformation templates for each service (including the parameters.json) and deploys the app. Where does this "master" cloudformation template get stored. For example in the API resource, there is an api-params.json file specifying the endpoint restrictions based on auth roles, but I do not see those in the api cloudformation template. How would I see the final template with the auth restrictions applied to the API Gateway resources?
You can see your nested Stack and all the templates in the AWS Console -> CloudFormation.
You can see the templates in your code repository locally after performing amplify pull in the amplify/backend/#current-cloud-backend
You can see the templates stored in S3 in your deployment bucket e.g., s3://amplify-appName-envName-someId-deployment/amplify-cfn-templates

Is bitbucket enterprise server allowed with AWS codebuild?

I am looking to integrate enterprise bitbucket server with aws ci/cd pipeline features.
I have tried creating a project within aws codebuild but do not see any option for bitbucket enterprise .
If this is not possible then what is the long route using api gateway / webhooks etc ?
AWS Codebuild only supports the Bitbucket cloud. To integrate with Bitbucket self hosted solution, you will need to create a API gateway + Lambda. And then add this gateway address as a webhook in the bitbucket repo. The Lambda will then be responsible to process the incoming events from Bitbucket server. There could be 2 routes from here.
One way could be to download the zip for the particular commit and upload it on a S3 bucket. Add S3 as a source trigger for the build project. You lose the ability to run any git specific commands in such a case though as it's just a zip file containing the specific version of files.
Second option could be to pass on the relevant info to codebuild by directly invoking it from Lambda. Passing off details like commit_id, event (pr or push), branch etc as environment variables. Based on this info, run a git clone in codebuild before running other build steps. This way you would have access to git specific commands.
Here is an example workflow from AWS (it is for codepipeline, but you can modify it suitably for codebuild)

Is it possible to combine AWS CodeBuild and CodePipeline to build described CI workflow?

What I'm trying to do is to create a following CI flow with standard AWS tools: run a build of a commit when a Pull Request in Github is created or updated. Or run a build of any branch on my command. Very similar to what Codeship, Travis and many other CI services offer.
Is it possible with CodeBuild + CodePipeline? I noticed that I have to specify exact branch in CodePipeline and, unfortunately, could not find how to integrate Github Pull requests into it. Maybe I overlooked it?
CodeBuild now directly supports building GitHub pull requests (without Lambda intermediate step), if you're looking to simply run a build as part of the PR. For running more steps with CodePipeline as part of a PR, you'll still need to set up some scaffolding as the other answers suggest.
https://aws.amazon.com/about-aws/whats-new/2017/09/aws-codebuild-now-supports-building-github-pull-requests/
CodePipeline does support basic, fully-managed integrations with both GitHub and CodeBuild, as listed in Product and Service Integrations with AWS CodePipeline. With these integrations, it is possible to use CodeBuild with CodePipeline to run a build of a commit when a commit is pushed to a branch on GitHub. See Use AWS CodePipeline with AWS CodeBuild to Run Builds for details on integrating CodeBuild with CodePipeline as a Build action provider, and see the Four-Stage Pipeline Tutorial for details on integrating Github with CodePipeline as a Source action provider.
Currently, the Pull Request feature in Github is not supported in the official CodePipeline integration, you did not overlook anything. For an interesting AWS-ecosystem open source project (not yet v1.0) that does support GitHub Pull Request integration (though not yet CodePipeline), you might want to check out LambCI.
It looks like this can be done somewhat manually by using Lambda and S3 - https://aws.amazon.com/blogs/devops/integrating-git-with-aws-codepipeline/
Webhooks notify a remote service by issuing an HTTP POST when a commit is pushed to the repository. AWS Lambda receives the HTTP POST through Amazon API Gateway, and then downloads a copy of the repository. It places a zipped copy of the repository into a versioned S3 bucket. AWS CodePipeline can then use the zip file in S3 as a source; the pipeline will be triggered whenever the Git repository is updated.
You could try https://www.deploytoproduction.com for Github Pull Request build status integration with AWS CodeBuild. It is free for a single Github repository with a subscription plan available for multiple repositories.
The service doesn't currently integrate with CodePipeline but that is coming soon.
If you wanted to build something yourself, you could make a new integration on GitHub that uses the webhook functionality to trigger a lambda function which in turn triggers your CodeBuild jobs or pushes an artifact to S3 to start a CodePipeline.
Full disclosure I am the author of this service