Skip to content

Commit

Permalink
feat: work on PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
luhanamz committed Sep 3, 2021
1 parent f05328b commit 296630f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DEPLOYMENT_MECHANISM } from './base-api-stack';
import { GitHubSourceActionInfo } from './pipeline-with-awaiter';
import { API_TYPE, IMAGE_SOURCE_TYPE, ResourceDependency, ServiceConfiguration } from './service-walkthroughs/containers-walkthrough';
import { ApiResource, generateContainersArtifacts } from './utils/containers-artifacts';
import {addCustomPoliciesFile} from "amplify-cli-core";
import { addCustomPoliciesFile, pathManager } from "amplify-cli-core";

export const addResource = async (
serviceWalkthroughPromise: Promise<ServiceConfiguration>,
Expand Down Expand Up @@ -99,6 +99,8 @@ export const addResource = async (

addCustomPoliciesFile(category, resourceName);

const customPoliciesPath = pathManager.getCustomPoliciesPath(category, resourceName);

context.print.success(`Successfully added resource ${resourceName} locally.`);
context.print.info('');
context.print.success('Next steps:');
Expand All @@ -114,6 +116,7 @@ export const addResource = async (
context.print.info(
`- Amplify CLI infers many configuration settings from the "docker-compose.yaml" file. Learn more: docs.amplify.aws/cli/usage/containers`,
);
context.print.info(`- To access AWS resources outside of this Amplify app, edit the ${customPoliciesPath}`);
context.print.info('- Run "amplify push" to build and deploy your image');

return resourceName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,16 @@ export async function addFunctionResource(

const { print } = context;


const customPoliciesPath = pathManager.getCustomPoliciesPath(category, completeParams.resourceName);

print.success(`Successfully added resource ${completeParams.resourceName} locally.`);
print.info('');
print.success('Next steps:');
print.info(`Check out sample function code generated in <project-dir>/amplify/backend/function/${completeParams.resourceName}/src`);
print.info('"amplify function build" builds all of your functions currently in the project');
print.info('"amplify mock function <functionName>" runs your function locally');
print.info(`To access AWS resources outside of this Amplify app, edit the ${customPoliciesPath}`);
print.info('"amplify push" builds all of your local backend resources and provisions them in the cloud');
print.info(
'"amplify publish" builds all of your local backend and front-end resources (if you added hosting category) and provisions them in the cloud',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function validateCustomPolicy(customPolicy: CustomIAMPolicy, category: string, r
let errorMessage = "";

for (const resource of resources) {
if (!(resourceRegex.test(resource) && resource === '*')) {
if (!(resourceRegex.test(resource) || resource === '*')) {
wrongResourcesRegex.push(resource);
}
}
Expand Down Expand Up @@ -179,7 +179,12 @@ async function replaceEnvForCustomPolicies(policy: CustomIAMPolicy, currentEnv:
Resource: []
}
for (let resource of policy.Resource){
resourceWithEnv.push(resource.replace( '{env}', currentEnv));
if (resource.includes('{env}')) {
resourceWithEnv.push(Fn.Sub(resource, {'env': Fn.Ref('env')}));
}
else {
resourceWithEnv.push(resource);
}
}
customIAMpolicy.Resource = resourceWithEnv;
return customIAMpolicy;
Expand Down

0 comments on commit 296630f

Please sign in to comment.